mirror of
https://github.com/flarum/core.git
synced 2025-07-31 21:50:50 +02: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:
committed by
Franz Liedke
parent
208bad393f
commit
167059027e
@@ -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;
|
||||
|
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());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user