Increasing test coverage (#1711)

* added a few more tests, renamed singular to plural to match controller

* increase error reporting

* removed debugging and wait for tests
This commit is contained in:
Daniël Klabbers 2019-01-01 21:02:18 +01:00 committed by Franz Liedke
parent 208bad393f
commit 167059027e
5 changed files with 117 additions and 1 deletions

View File

@ -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

View File

@ -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;

View File

@ -0,0 +1,33 @@
<?php
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* 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']));
}
}

View File

@ -0,0 +1,40 @@
<?php
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* 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());
}
}

View File

@ -0,0 +1,40 @@
<?php
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* 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());
}
}