Abstract Class luya\testsuite\scopes\BaseScope

Inheritanceluya\testsuite\scopes\BaseScope
Subclassesluya\testsuite\scopes\PageScope, luya\testsuite\scopes\PermissionScope
Available since version1.0.21
Source Code https://github.com/luyadev/luya-testsuite/blob/master/src/scopes/BaseScope.php

Base Class for Scoped Actions.

Public Methods

Hide inherited methods

Method Description Defined By
__construct() Permission Scope contstructor. luya\testsuite\scopes\BaseScope
cleanup() Clean up tables and fixtures. luya\testsuite\scopes\BaseScope
cleanupFixture() A helper method to cleanup fixtures. luya\testsuite\scopes\BaseScope
configure() Configured is used before prepare which allows you to configure the current scope. luya\testsuite\scopes\BaseScope
getApp() Returns the Application instance. luya\testsuite\scopes\BaseScope
prepare() This method is called before the callback runs in order to prepare and setup the permission scope. luya\testsuite\scopes\BaseScope
run() Run a given function inside a permission scope. luya\testsuite\scopes\BaseScope
runCallable() Run the provided callable function luya\testsuite\scopes\BaseScope

Method Details

Hide inherited methods

__construct() public method

Permission Scope contstructor.

public void __construct ( yii\base\Application $app, callable $fn, callable $invoke null )
$app yii\base\Application
$fn callable
$invoke callable

                public function __construct(Application $app, callable $fn, callable $invoke = null)
{
    $this->_app = $app;
    $this->_invoke = $invoke;
    $this->_fn = $fn;    
}

            
cleanup() public abstract method

Clean up tables and fixtures.

public abstract void cleanup ( )

                abstract public function cleanup();

            
cleanupFixture() public method

A helper method to cleanup fixtures.

If the given fixture property is not an instance of ActiveRecordFixture nothing happens, otherwise the cleanup() will be run.

public void cleanupFixture ( $fixture )
$fixture mixed

                public function cleanupFixture($fixture)
{
    if ($fixture instanceof ActiveRecordFixture) {
        $fixture->cleanup();
    }
}

            
configure() public method

Configured is used before prepare which allows you to configure the current scope.

public void configure ( )

                public function configure()
{
    if ($this->_invoke) {
        call_user_func_array($this->_invoke, [$this]);
    }
}

            
getApp() public method

Returns the Application instance.

Getter method to access the private object.

public yii\base\Application getApp ( )

                public function getApp()
{
    return $this->_app;
}

            
prepare() public abstract method

This method is called before the callback runs in order to prepare and setup the permission scope.

public abstract void prepare ( )

                abstract public function prepare();

            
run() public static method

Run a given function inside a permission scope.

public static mixed run ( yii\base\Application $app, callable $fn, callable $invoke null )
$app \luya\testsuite\scopes\yii\base\Application
$fn callable

The function to run.

$invoke callable

The function to configure the scope.

                public static function run(Application $app, callable $fn, callable $invoke = null)
{
    $scope = new static($app, $fn, $invoke);
    $scope->configure();
    $scope->prepare();
    $response = $scope->runCallable($scope);
    $scope->cleanup();
    return $response;
}

            
runCallable() public method

Run the provided callable function

public mixed runCallable ( luya\testsuite\scopes\BaseScope $scope )
$scope luya\testsuite\scopes\PermissionScope

                public function runCallable(BaseScope $scope)
{
    return call_user_func_array($this->_fn, [$scope]);
}