mirror of
https://github.com/flarum/framework.git
synced 2025-01-19 18:12:59 +08:00
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:
parent
208bad393f
commit
167059027e
|
@ -9,6 +9,9 @@ install:
|
||||||
- composer install
|
- composer install
|
||||||
- mysql -e 'CREATE DATABASE flarum;'
|
- mysql -e 'CREATE DATABASE flarum;'
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- echo 'error_reporting = E_ALL' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- vendor/bin/phpunit --coverage-clover=coverage.xml
|
- vendor/bin/phpunit --coverage-clover=coverage.xml
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace Flarum\Tests\Api\Controller;
|
||||||
use Flarum\Api\Controller\ListDiscussionsController;
|
use Flarum\Api\Controller\ListDiscussionsController;
|
||||||
use Flarum\Discussion\Discussion;
|
use Flarum\Discussion\Discussion;
|
||||||
|
|
||||||
class ListDiscussionControllerTest extends ApiControllerTestCase
|
class ListDiscussionsControllerTest extends ApiControllerTestCase
|
||||||
{
|
{
|
||||||
protected $controller = ListDiscussionsController::class;
|
protected $controller = ListDiscussionsController::class;
|
||||||
|
|
33
tests/Api/Controller/ListGroupsControllerTest.php
Normal file
33
tests/Api/Controller/ListGroupsControllerTest.php
Normal 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']));
|
||||||
|
}
|
||||||
|
}
|
40
tests/Api/Controller/ListNotificationsControllerTest.php
Normal file
40
tests/Api/Controller/ListNotificationsControllerTest.php
Normal 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());
|
||||||
|
}
|
||||||
|
}
|
40
tests/Api/Controller/ListUsersControllerTest.php
Normal file
40
tests/Api/Controller/ListUsersControllerTest.php
Normal 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());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user