From f970ae7100d44aaaa20e71193aa9290e7dbe53ec Mon Sep 17 00:00:00 2001 From: James Brooks Date: Mon, 1 Jun 2015 21:32:02 +0100 Subject: [PATCH] Start working on API tests --- bootstrap/cache/.gitignore | 0 composer.json | 5 ++++- tests/Api/ComponentTest.php | 36 ++++++++++++++++++++++++++++++++++++ tests/Api/IncidentTest.php | 25 +++++++++++++++++++++++++ tests/Api/MetricTest.php | 25 +++++++++++++++++++++++++ 5 files changed, 90 insertions(+), 1 deletion(-) mode change 100644 => 100755 bootstrap/cache/.gitignore create mode 100644 tests/Api/ComponentTest.php create mode 100644 tests/Api/IncidentTest.php create mode 100644 tests/Api/MetricTest.php diff --git a/bootstrap/cache/.gitignore b/bootstrap/cache/.gitignore old mode 100644 new mode 100755 diff --git a/composer.json b/composer.json index 589ed254..3bfab775 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,10 @@ "barryvdh/laravel-cors": "^0.5" }, "require-dev": { - "graham-campbell/testbench": "^2.1" + "graham-campbell/testbench": "^2.1", + "fzaninotto/faker": "~1.4", + "mockery/mockery": "0.9.*", + "phpunit/phpunit": "~4.0" }, "autoload": { "classmap": [ diff --git a/tests/Api/ComponentTest.php b/tests/Api/ComponentTest.php new file mode 100644 index 00000000..2c49e928 --- /dev/null +++ b/tests/Api/ComponentTest.php @@ -0,0 +1,36 @@ + + * + * 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; +use Illuminate\Foundation\Testing\DatabaseMigrations; + +class ComponentTest extends AbstractTestCase +{ + use DatabaseMigrations; + + public function testGetComponents() + { + $this->get('/api/v1/components')->seeJson(['data' => []]); + } + + public function testGetInvalidComponent() + { + $this->setExpectedException('Illuminate\Database\Eloquent\ModelNotFoundException'); + $this->get('/api/v1/components/1'); + } + + /*public function testPostComponentUnauthorized() + { + $this->post('/api/v1/components')->seeJson(['data']); + }*/ +} diff --git a/tests/Api/IncidentTest.php b/tests/Api/IncidentTest.php new file mode 100644 index 00000000..bf6deba2 --- /dev/null +++ b/tests/Api/IncidentTest.php @@ -0,0 +1,25 @@ + + * + * 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; +use Illuminate\Foundation\Testing\DatabaseMigrations; + +class IncidentTest extends AbstractTestCase +{ + use DatabaseMigrations; + + public function testGetIncidents() + { + $this->get('/api/v1/incidents')->seeJson(['data' => []]); + } +} diff --git a/tests/Api/MetricTest.php b/tests/Api/MetricTest.php new file mode 100644 index 00000000..58671bbf --- /dev/null +++ b/tests/Api/MetricTest.php @@ -0,0 +1,25 @@ + + * + * 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; +use Illuminate\Foundation\Testing\DatabaseMigrations; + +class MetricTest extends AbstractTestCase +{ + use DatabaseMigrations; + + public function testGetMetrics() + { + $this->get('/api/v1/metrics')->seeJson(['data' => []]); + } +}