Bake\Shell\Task\TestTask::buildTestSubject PHP Метод

buildTestSubject() публичный Метод

So that fixtures can be detected
public buildTestSubject ( string $type, string $class ) : object
$type string The type of object you are generating tests for eg. controller
$class string The classname of the class the test is being generated for.
Результат object And instance of the class that is going to be tested.
    public function buildTestSubject($type, $class)
    {
        if (strtolower($type) === 'table') {
            list(, $name) = namespaceSplit($class);
            $name = str_replace('Table', '', $name);
            if ($this->plugin) {
                $name = $this->plugin . '.' . $name;
            }
            if (TableRegistry::exists($name)) {
                $instance = TableRegistry::get($name);
            } else {
                $instance = TableRegistry::get($name, ['connectionName' => $this->connection]);
            }
        } elseif (strtolower($type) === 'controller') {
            $instance = new $class(new Request(), new Response());
        } else {
            $instance = new $class();
        }
        return $instance;
    }