for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
class AdminPageTest extends TestCase {
You can fix this by adding a namespace to your class:
namespace YourVendor; class YourClass { }
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.
/**
* Make sure public can't access admin pages
*
* @dataProvider pubUsers
* @param callable $userCb
* @return void
*/
public function testMakeSurePublicCantAccess($userCb) {
// Set current user
$user = $userCb();
$this->flushSession();
Route::enableFilters();
if ($user) {
$this->be($user);
}
// get admin homepage
$this->client->request('GET', '/admin');
$this->assertTrue($this->client->getResponse()->isRedirection());
Route::disableFilters();
* Return public users to test with.
* Because this is ran before application is created it returns callbacks.
* @return array
public function pubUsers() {
return [
[function () {
return null;
}], // Not logged in
User::find(2);
}], // Nonadmin user
];
public function testAdminHomepage() {
/** @type User $user */
$user = User::find(1);
$this->assertTrue($this->client->getResponse()->isOk());
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.