diff --git a/app/Http/Controllers/Api/GeneralController.php b/app/Http/Controllers/Api/GeneralController.php new file mode 100644 index 00000000..9214b9a8 --- /dev/null +++ b/app/Http/Controllers/Api/GeneralController.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace CachetHQ\Cachet\Http\Controllers\Api; + +class GeneralController extends AbstractApiController +{ + public function ping() + { + return $this->item('Pong!'); + } +} diff --git a/app/Http/Routes/ApiRoutes.php b/app/Http/Routes/ApiRoutes.php index 1d833835..0e896dbd 100644 --- a/app/Http/Routes/ApiRoutes.php +++ b/app/Http/Routes/ApiRoutes.php @@ -26,6 +26,9 @@ class ApiRoutes 'namespace' => 'Api', 'prefix' => 'api/v1', ], function ($router) { + // General + $router->get('ping', 'GeneralController@ping'); + // Components $router->get('components', 'ComponentController@getComponents'); $router->get('components/{id}', 'ComponentController@getComponent'); diff --git a/tests/Api/GeneralTest.php b/tests/Api/GeneralTest.php new file mode 100644 index 00000000..635d8962 --- /dev/null +++ b/tests/Api/GeneralTest.php @@ -0,0 +1,24 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace CachetHQ\Tests\Cachet\Api; + +use CachetHQ\Tests\Cachet\AbstractTestCase; + +class GeneralTest extends AbstractTestCase +{ + public function testGetPing() + { + $this->get('/api/v1/ping'); + $this->seeJson(['data' => 'Pong!']); + $this->assertResponseOk(); + } +}