PHP Класс Bake\Shell\Task\TestTask

Наследование: extends Bake\Shell\Task\BakeTask
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$classSuffixes array class types that methods can be generated for
$classTypes array class types that methods can be generated for
$tasks array Tasks used.

Защищенные свойства (Protected)

Свойство Тип Описание
$_fixtures array Internal list of fixtures that have been added so far.

Открытые методы

Метод Описание
bake ( string $type, string $className ) : string | boolean Completes final steps for generating data to create test case.
buildTestSubject ( string $type, string $class ) : object Construct an instance of the class to be tested.
generateConstructor ( string $type, string $fullClassName ) : array Generate a constructor code snippet for the type and class name
generateFixtureList ( object $subject ) : array Generate the list of fixtures that will be required to run this test based on loaded models.
generateProperties ( string $type, string $subject, string $fullClassName ) : array Generate property info for the type and class name
generateUses ( string $type, string $fullClassName ) : array Generate the uses() calls for a type & class name
getOptionParser ( ) : Cake\Console\ConsoleOptionParser Gets the option parser instance and configures it.
getPath ( ) : string Get the file path.
getRealClassName ( string $type, string $class ) : string Gets the real class name from the cake short form. If the class name is already suffixed with the type, the type will not be duplicated.
getSubspacePath ( string $type ) : string Gets the subspace path for a test.
getTestableMethods ( string $className ) : array Get methods declared in the class given.
hasMockClass ( string $type ) : boolean Is a mock class required for this type of test? Controllers require a mock class.
main ( string | null $type = null, string | null $name = null ) : void | array Execution method always used for tasks
mapType ( string $type ) : string Map the types that TestTask uses to concrete types that App::className can use.
outputClassChoices ( string $type ) : array Output a list of possible classnames you might want to generate a test for.
outputTypeChoices ( ) : void Output a list of class types you can bake a test for.
testCaseFileName ( string $type, string $className ) : string Make the filename for the test case. resolve the suffixes for controllers and get the plugin path if needed.
typeCanDetectFixtures ( string $type ) : boolean Checks whether the chosen type can find its own fixtures.

Защищенные методы

Метод Описание
_addFixture ( string $name ) : void Add class name to the fixture list.
_bakeAll ( string $type ) : void
_getClassOptions ( string $namespace ) : array Get the possible classes for a given type.
_processController ( Controller $subject ) : void Process all the models attached to a controller and generate a fixture list.
_processModel ( Model $subject ) : void Process a model recursively and pull out all the model names converting them to fixture names.

Описание методов

_addFixture() защищенный Метод

Sets the app. or plugin.plugin_name. prefix.
protected _addFixture ( string $name ) : void
$name string Name of the Model class that a fixture might be required for.
Результат void

_bakeAll() защищенный Метод

protected _bakeAll ( string $type ) : void
$type string The typename to get bake all classes for.
Результат void

_getClassOptions() защищенный Метод

Get the possible classes for a given type.
protected _getClassOptions ( string $namespace ) : array
$namespace string The namespace fragment to look for classes in.
Результат array

_processController() защищенный Метод

Process all the models attached to a controller and generate a fixture list.
protected _processController ( Controller $subject ) : void
$subject Cake\Controller\Controller A controller to pull model names off of.
Результат void

_processModel() защищенный Метод

Process a model recursively and pull out all the model names converting them to fixture names.
protected _processModel ( Model $subject ) : void
$subject Model A Model class to scan for associations and pull fixtures off of.
Результат void

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

Completes final steps for generating data to create test case.
public bake ( string $type, string $className ) : string | boolean
$type string Type of object to bake test case for ie. Model, Controller
$className string the 'cake name' for the class ie. Posts for the PostsController
Результат string | boolean

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.

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

Generate a constructor code snippet for the type and class name
public generateConstructor ( string $type, string $fullClassName ) : array
$type string The Type of object you are generating tests for eg. controller
$fullClassName string The full classname of the class the test is being generated for.
Результат array Constructor snippets for the thing you are building.

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

Generate the list of fixtures that will be required to run this test based on loaded models.
public generateFixtureList ( object $subject ) : array
$subject object The object you want to generate fixtures for.
Результат array Array of fixtures to be included in the test.

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

The generated property info consists of a set of arrays that hold the following keys: - description (the property description) - type (the property docblock type) - name (the property name) - value (optional - the properties initial value)
public generateProperties ( string $type, string $subject, string $fullClassName ) : array
$type string The Type of object you are generating tests for eg. controller
$subject string The name of the test subject.
$fullClassName string The Classname of the class the test is being generated for.
Результат array An array containing property info

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

Generate the uses() calls for a type & class name
public generateUses ( string $type, string $fullClassName ) : array
$type string The Type of object you are generating tests for eg. controller
$fullClassName string The Classname of the class the test is being generated for.
Результат array An array containing used classes

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

Gets the option parser instance and configures it.
public getOptionParser ( ) : Cake\Console\ConsoleOptionParser
Результат Cake\Console\ConsoleOptionParser

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

Get the file path.
public getPath ( ) : string
Результат string

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

Gets the real class name from the cake short form. If the class name is already suffixed with the type, the type will not be duplicated.
public getRealClassName ( string $type, string $class ) : string
$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.
Результат string Real class name

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

Gets the subspace path for a test.
public getSubspacePath ( string $type ) : string
$type string The Type of object you are generating tests for eg. controller.
Результат string Path of the subspace.

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

No parent methods will be returned
public getTestableMethods ( string $className ) : array
$className string Name of class to look at.
Результат array Array of method names.

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

Is a mock class required for this type of test? Controllers require a mock class.
public hasMockClass ( string $type ) : boolean
$type string The type of object tests are being generated for eg. controller.
Результат boolean

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

Execution method always used for tasks
public main ( string | null $type = null, string | null $name = null ) : void | array
$type string | null Class type.
$name string | null Name.
Результат void | array

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

Map the types that TestTask uses to concrete types that App::className can use.
public mapType ( string $type ) : string
$type string The type of thing having a test generated.
Результат string

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

Output a list of possible classnames you might want to generate a test for.
public outputClassChoices ( string $type ) : array
$type string The typename to get classes for.
Результат array

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

Output a list of class types you can bake a test for.
public outputTypeChoices ( ) : void
Результат void

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

Make the filename for the test case. resolve the suffixes for controllers and get the plugin path if needed.
public testCaseFileName ( string $type, string $className ) : string
$type string The Type of object you are generating tests for eg. controller
$className string The fully qualified classname of the class the test is being generated for.
Результат string filename the test should be created on.

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

Currently only model, and controller are supported
public typeCanDetectFixtures ( string $type ) : boolean
$type string The Type of object you are generating tests for eg. controller
Результат boolean

Описание свойств

$_fixtures защищенное свойство

Internal list of fixtures that have been added so far.
protected array $_fixtures
Результат array

$classSuffixes публичное свойство

class types that methods can be generated for
public array $classSuffixes
Результат array

$classTypes публичное свойство

class types that methods can be generated for
public array $classTypes
Результат array

$tasks публичное свойство

Tasks used.
public array $tasks
Результат array