PHP 클래스 Bake\Shell\Task\TestTask

상속: extends Bake\Shell\Task\BakeTask
파일 보기 프로젝트 열기: cakephp/bake 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$classSuffixes array class types that methods can be generated for
$classTypes array class types that methods can be generated for
$tasks array Tasks used.

보호된 프로퍼티들

프로퍼티 타입 설명
$_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