Properties

$plugin

$plugin : array

Plugin name

Type

array

$data

$data : array

Post data

Type

array

$_controller

$_controller : string

Controller name

Type

string

$_isFixtureMerged

$_isFixtureMerged : boolean

Fixture merge

Type

boolean

$_fixtures

$_fixtures : array

Fixtures

Type

array

$_helperName

$_helperName : string

Helper name

Type

string

Methods

loadTestPlugin()

loadTestPlugin(\CakeTestCase  $test, string  $plugin, string  $testPlugin) : void

Load TestPlugin

Parameters

\CakeTestCase $test

CakeTestCase

string $plugin

Plugin name

string $testPlugin

Test plugin name

asserts()

asserts(array  $asserts, string  $result) : void

Asserts

Parameters

array $asserts

テストAssert

string $result

Result data

assertInput()

assertInput(string  $tagType, string  $name, string  $value, string  $result, string  $message = null) : void

Assert input tag

Parameters

string $tagType

タグタイプ(input or textearea or button)

string $name

inputタグのname属性

string $value

inputタグのvalue値

string $result

Result data

string $message

メッセージ

assertActionLink()

assertActionLink(string  $action, array  $urlOptions, boolean  $linkExist, string  $result, string  $message = null) : void

Assert アクションリンク

Parameters

string $action

アクション

array $urlOptions

URLオプション

boolean $linkExist

リンクの有無

string $result

Result data

string $message

メッセージ

__construct()

__construct(string  $name = null, array  $data = array(), string  $dataName = '') : void

Fixtures load

Parameters

string $name

The name parameter on PHPUnit_Framework_TestCase::__construct()

array $data

The date parameter on PHPUnit_Framework_TestCase::__construct()

string $dataName

The dataName parameter on PHPUnit_Framework_TestCase::__construct()

setUp()

setUp() : void

setUp method

tearDown()

tearDown() : void

tearDown method

generateNc()

generateNc(string  $controller, array  $mocks = array()) : \Controller

Generates a mocked controller and mocks any classes passed to `$mocks`. By default, `_stop()` is stubbed as is sending the response headers, so to not interfere with testing.

Mocks:

  • methods Methods to mock on the controller. _stop() is mocked by default
  • models Models to mock. Models are added to the ClassRegistry so any time they are instantiated the mock will be created. Pass as key value pairs with the value being specific methods on the model to mock. If true or no value is passed, the entire model will be mocked.
  • components Components to mock. Components are only mocked on this controller and not within each other (i.e., components on components)

Parameters

string $controller

Controller name

array $mocks

List of classes and methods to mock

Returns

\Controller —

Mocked controller

assertDatetime()

assertDatetime(string  $result, string  $message = null) : void

Assert Date time

Parameters

string $result

Result data

string $message

メッセージ

assertRedirect()

assertRedirect(string  $result, string  $message = null) : void

リダイレクトの評価

Parameters

string $result

期待値

string $message

メッセージ

loadHelper()

loadHelper(string  $helper, array  $viewVars = array(), array  $reqestData = array(), array  $params = array(), array  $helpers = array(), array  $validationErrors = null, array  $controllerVars = array()) : void

Helperのロード処理

Parameters

string $helper

ロードするHelper名(PluginName.HelperName)

array $viewVars

$helper->_View->viewVarsに値をセットする配列

array $reqestData

$helper->_View->request->dataに値をセットする配列

array $params

$helper->_View->paramsに値をセットする配列

array $helpers

ヘルパー配列

array $validationErrors

バリデーションエラー

array $controllerVars

コントローラ変数にセットする配列

_testAction()

_testAction(string  $url = '', array  $options = array()) : mixed

Lets you do functional tests of a controller action.

Options:

  • data Will be used as the request data. If the method is GET, data will be used a GET params. If the method is POST, it will be used as POST data. By setting $options['data'] to a string, you can simulate XML or JSON payloads to your controllers allowing you to test REST webservices.
  • method POST or GET. Defaults to POST.
  • return Specify the return type you want. Choose from:
    • vars Get the set view variables.
    • view Get the rendered view, without a layout.
    • contents Get the rendered view including the layout.
    • result Get the return value of the controller action. Useful for testing requestAction methods.
  • type json or html, Defaults to html.

Parameters

string $url

The url to test

array $options

See options

Returns

mixed

_testNcAction()

_testNcAction(array  $url = array(), array  $paramsOptions = array(), string|null  $exception = null, string  $return = 'view') : mixed

Assert input tag

$returnについて

  • viewFile: viewファイル名を戻す
  • json: JSONをでコードした配列を戻す
  • 上記以外: $this->testActionのreturnで指定した内容を戻す

Parameters

array $url

URL配列

array $paramsOptions

リクエストパラメータオプション

string|null $exception

Exception

string $return

testActionの実行後の結果

Returns

mixed

_testGetAction()

_testGetAction(array  $urlOptions, array  $assert, string|null  $exception = null, string  $return = 'view') : mixed

viewアクションのテスト

Parameters

array $urlOptions

URLオプション

array $assert

テストの期待値

string|null $exception

Exception

string $return

testActionの実行後の結果

Returns

mixed —

テスト結果

_testPostAction()

_testPostAction(array  $method, array  $data, array  $urlOptions, string|null  $exception = null, string  $return = 'view') : mixed

addアクションのPOSTテスト

Parameters

array $method

リクエストのmethod(post put delete)

array $data

POSTデータ

array $urlOptions

URLオプション

string|null $exception

Exception

string $return

testActionの実行後の結果

Returns

mixed —

テスト結果

_testActionOnValidationError()

_testActionOnValidationError(array  $method, array  $data, array  $urlOptions, string|null  $validError = null) : mixed

addアクションのValidateionErrorテスト

Parameters

array $method

リクエストのmethod(post put delete)

array $data

POSTデータ

array $urlOptions

URLオプション

string|null $validError

ValidationError

Returns

mixed —

テスト結果

_mockForReturnFalse()

_mockForReturnFalse(string  $mockModel, string  $mockMethod, integer|string  $count = 1) : void

戻り値FalseのMockセット

Parameters

string $mockModel

Mockのモデル

string $mockMethod

Mockのメソッド

integer|string $count

Mockの呼び出し回数

_mockForReturnTrue()

_mockForReturnTrue(string  $mockModel, string  $mockMethod, integer|string  $count = 1) : void

戻り値TrueのMockセット

Parameters

string $mockModel

Mockのモデル

string $mockMethod

Mockのメソッド

integer|string $count

Mockの呼び出し回数

_mockForReturn()

_mockForReturn(string  $mockModel, string  $mockMethod, boolean  $return, integer|string  $count = 1) : void

戻り値指定のMockセット

Parameters

string $mockModel

Mockのモデル

string $mockMethod

Mockのメソッド

boolean $return

戻り値

integer|string $count

Mockの呼び出し回数

_mockForReturnCallback()

_mockForReturnCallback(string  $mockModel, string  $mockMethod, mixed  $callback) : void

CallbackのMockセット

Parameters

string $mockModel

Mockのモデル

string $mockMethod

Mockのメソッド

mixed $callback

コールバック関数

_clear()

_clear() : void

初期化

_testReflectionMethod()

_testReflectionMethod(\Instance  $instance, string  $mockMethod, array  $params = array()) : void

privateおよびprotectedメソッドのテスト

Parameters

\Instance $instance

インスタンス

string $mockMethod

Mockのメソッド

array $params

Mockのメソッドのパラメータ

_parseView()

_parseView(string  $view) : string

Viewの結果をスペース等のパースを行う

Parameters

string $view

Viewの結果

Returns

string