-
-
Notifications
You must be signed in to change notification settings - Fork 834
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added a few more tests, renamed singular to plural to match controller * increase error reporting * removed debugging and wait for tests
- Loading branch information
1 parent
208bad3
commit 1670590
Showing
5 changed files
with
117 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'])); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()); | ||
} | ||
} |