2019-11-23 22:05:38 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
use Illuminate\Routing\RouteCollection;
|
|
|
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
|
use Illuminate\Support\Facades\Route;
|
|
|
|
|
use Webkul\User\Models\Admin;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Inherited Methods
|
|
|
|
|
* @method void wantToTest($text)
|
|
|
|
|
* @method void wantTo($text)
|
|
|
|
|
* @method void execute($callable)
|
|
|
|
|
* @method void expectTo($prediction)
|
|
|
|
|
* @method void expect($prediction)
|
|
|
|
|
* @method void amGoingTo($argumentation)
|
|
|
|
|
* @method void am($role)
|
|
|
|
|
* @method void lookForwardTo($achieveValue)
|
|
|
|
|
* @method void comment($description)
|
|
|
|
|
* @method void pause()
|
|
|
|
|
*
|
|
|
|
|
* @SuppressWarnings(PHPMD)
|
|
|
|
|
*/
|
|
|
|
|
class FunctionalTester extends \Codeception\Actor
|
|
|
|
|
{
|
|
|
|
|
use _generated\FunctionalTesterActions;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Define custom actions here
|
|
|
|
|
*/
|
|
|
|
|
|
2019-11-23 22:09:39 +00:00
|
|
|
/**
|
|
|
|
|
* Login as default administrator
|
|
|
|
|
*/
|
2019-11-23 22:05:38 +00:00
|
|
|
public function loginAsAdmin(): void
|
|
|
|
|
{
|
|
|
|
|
$I = $this;
|
|
|
|
|
|
|
|
|
|
Auth::guard('admin')->login($I->grabRecord(Admin::class, ['email' => 'admin@example.com']));
|
|
|
|
|
$I->seeAuthentication('admin');
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-23 22:09:39 +00:00
|
|
|
/**
|
|
|
|
|
* Go to a specific route and check if admin guard is applied on it
|
|
|
|
|
*
|
|
|
|
|
* @param string $name name of the route
|
|
|
|
|
* @param array|null $params params the route will be created with
|
|
|
|
|
*/
|
2019-11-23 22:05:38 +00:00
|
|
|
public function amOnAdminRoute(string $name, array $params = null): void
|
|
|
|
|
{
|
|
|
|
|
$I = $this;
|
|
|
|
|
$I->amOnRoute($name, $params);
|
|
|
|
|
$I->seeCurrentRouteIs($name);
|
|
|
|
|
|
|
|
|
|
/** @var RouteCollection $routes */
|
|
|
|
|
$routes = Route::getRoutes();
|
|
|
|
|
$middlewares = $routes->getByName($name)->middleware();
|
|
|
|
|
$I->assertContains('admin', $middlewares, 'check that admin middleware is applied');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|