$plugin
$plugin : string
Plugin name
NetCommonsControllerTestCase
__construct(string $name = null, array $data = array(), string $dataName = '') : void
Fixtures load
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() |
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.
methods
Methods to mock on the controller. _stop()
is mocked by defaultmodels
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)string | $controller | Controller name |
array | $mocks | List of classes and methods to mock |
Mocked controller
assertInput(string $tagType, string $name, string $value, string $result, string $message = null) : void
Assert input tag
string | $tagType | タグタイプ(input or textearea or button) |
string | $name | inputタグのname属性 |
string | $value | inputタグのvalue値 |
string | $result | Result data |
string | $message | メッセージ |
_testAction(string $url = '', array $options = array()) : mixed
Lets you do functional tests of a controller action.
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.string | $url | The url to test |
array | $options | See options |
_testNcAction(array $url = array(), array $paramsOptions = array(), string|null $exception = null, string $return = 'view') : mixed
Assert input tag
array | $url | URL配列 |
array | $paramsOptions | リクエストパラメータオプション |
string|null | $exception | Exception |
string | $return | testActionの実行後の結果 |
_testPostAction(array $method, array $data, array $urlOptions, string|null $exception = null, string $return = 'view') : mixed
addアクションのPOSTテスト
array | $method | リクエストのmethod(post put delete) |
array | $data | POSTデータ |
array | $urlOptions | URLオプション |
string|null | $exception | Exception |
string | $return | testActionの実行後の結果 |
テスト結果
_testActionOnValidationError(array $method, array $data, array $urlOptions, string|null $validError = null) : mixed
addアクションのValidateionErrorテスト
array | $method | リクエストのmethod(post put delete) |
array | $data | POSTデータ |
array | $urlOptions | URLオプション |
string|null | $validError | ValidationError |
テスト結果