diff --git a/framework/core/.travis.yml b/framework/core/.travis.yml index c62d1e8d6..d4a4effca 100644 --- a/framework/core/.travis.yml +++ b/framework/core/.travis.yml @@ -9,6 +9,9 @@ install: - composer install - mysql -e 'CREATE DATABASE flarum;' +before_script: + - echo 'error_reporting = E_ALL' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini + script: - vendor/bin/phpunit --coverage-clover=coverage.xml diff --git a/framework/core/tests/Api/Controller/ListDiscussionControllerTest.php b/framework/core/tests/Api/Controller/ListDiscussionsControllerTest.php similarity index 94% rename from framework/core/tests/Api/Controller/ListDiscussionControllerTest.php rename to framework/core/tests/Api/Controller/ListDiscussionsControllerTest.php index 276d0273a..c7d2abe93 100644 --- a/framework/core/tests/Api/Controller/ListDiscussionControllerTest.php +++ b/framework/core/tests/Api/Controller/ListDiscussionsControllerTest.php @@ -14,7 +14,7 @@ namespace Flarum\Tests\Api\Controller; use Flarum\Api\Controller\ListDiscussionsController; use Flarum\Discussion\Discussion; -class ListDiscussionControllerTest extends ApiControllerTestCase +class ListDiscussionsControllerTest extends ApiControllerTestCase { protected $controller = ListDiscussionsController::class; diff --git a/framework/core/tests/Api/Controller/ListGroupsControllerTest.php b/framework/core/tests/Api/Controller/ListGroupsControllerTest.php new file mode 100644 index 000000000..34d945a90 --- /dev/null +++ b/framework/core/tests/Api/Controller/ListGroupsControllerTest.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Flarum\Tests\Api\Controller; + +use Flarum\Api\Controller\ListGroupsController; +use Flarum\Group\Group; + +class ListGroupsControllerTest extends ApiControllerTestCase +{ + protected $controller = ListGroupsController::class; + + /** + * @test + */ + public function shows_index_for_guest() + { + $response = $this->callWith(); + + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($response->getBody()->getContents(), true); + + $this->assertEquals(Group::count(), count($data['data'])); + } +} diff --git a/framework/core/tests/Api/Controller/ListNotificationsControllerTest.php b/framework/core/tests/Api/Controller/ListNotificationsControllerTest.php new file mode 100644 index 000000000..f269b8da8 --- /dev/null +++ b/framework/core/tests/Api/Controller/ListNotificationsControllerTest.php @@ -0,0 +1,40 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Flarum\Tests\Api\Controller; + +use Flarum\Api\Controller\ListNotificationsController; + +class ListNotificationsControllerTest extends ApiControllerTestCase +{ + protected $controller = ListNotificationsController::class; + + /** + * @test + * @expectedException \Flarum\User\Exception\PermissionDeniedException + */ + public function disallows_index_for_guest() + { + $this->callWith(); + } + + /** + * @test + */ + public function show_index_for_user() + { + $this->actor = $this->getNormalUser(); + + $response = $this->callWith(); + + $this->assertEquals(200, $response->getStatusCode()); + } +} diff --git a/framework/core/tests/Api/Controller/ListUsersControllerTest.php b/framework/core/tests/Api/Controller/ListUsersControllerTest.php new file mode 100644 index 000000000..34350db87 --- /dev/null +++ b/framework/core/tests/Api/Controller/ListUsersControllerTest.php @@ -0,0 +1,40 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Flarum\Tests\Api\Controller; + +use Flarum\Api\Controller\ListUsersController; + +class ListUsersControllerTest extends ApiControllerTestCase +{ + protected $controller = ListUsersController::class; + + /** + * @test + * @expectedException \Flarum\User\Exception\PermissionDeniedException + */ + public function disallows_index_for_guest() + { + $this->callWith(); + } + + /** + * @test + */ + public function shows_index_for_admin() + { + $this->actor = $this->getAdminUser(); + + $response = $this->callWith(); + + $this->assertEquals(200, $response->getStatusCode()); + } +}