CakePHP Cookbook 2.x
controllers and components easier. Instead of having methods spread across several objects, you only have to mock a single object, since controllers and components delegate to CakeResponse. This helps you to get knows to use your test database connection. Mocking model methods There will be times you’ll want to mock methods on models when testing them. You should use getMockForModel to create testing mocks of models cases allows you to use testAction() for simpler test cases. ControllerTestCase allows you to easily mock out components and models, as well as potentially difficult to test methods like redirect(). Say0 码力 | 1096 页 | 958.62 KB | 1 年前3
CakePHP Cookbook 2.x
controllers and components easier. Instead of having methods spread across several objects, you only have to mock a single object, since controllers and components delegate to CakeResponse. This helps you to get CakePHP Cookbook Documentation, Release 2.x Mocking model methods There will be times you’ll want to mock methods on models when testing them. You should use getMockForModel to create testing mocks of models cases allows you to use testAction() for simpler test cases. ControllerTestCase allows you to easily mock out components and models, as well as potentially difficult to test methods like redirect(). Say0 码力 | 820 页 | 2.52 MB | 1 年前3
CakePHP Cookbook Documentation 5.xias, $config) When loading tables from the registry you can customize their dependencies, or use mock objects by providing an $options array: $articles = FactoryLocator::get('Table')->get('Articles' During test cases you may want to flush the registry. Doing so is often useful when you are using mock objects, or modifying a table’s dependencies: FactoryLocator::get('Table')->clear(); Configuring provide many commonly used options to find(). This can help with testing as there are fewer methods to mock: // In a controller or table method. $query = $articles->find('all', conditions: ['Articles.created0 码力 | 1080 页 | 939.39 KB | 1 年前3
CakePHP Cookbook 4.x
This method enables services injected with the Dependency Injection container to be replaced with mock or stub objects. View Context classes now include the comment, null, and default metadata options ias, $config) When loading tables from the registry you can customize their dependencies, or use mock objects by providing an $options array: $articles = FactoryLocator::get('Table')->get('Articles' During test cases you may want to flush the registry. Doing so is often useful when you are using mock objects, or modifying a table’s dependencies: FactoryLocator::get('Table')->clear(); Configuring0 码力 | 1249 页 | 1.04 MB | 1 年前3
CakePHP Cookbook Documentation 5.xias, $config) When loading tables from the registry you can customize their dependencies, or use mock objects by providing an $options array: $articles = FactoryLocator::get('Table')->get('Articles' During test cases you may want to flush the registry. Doing so is often useful when you are using mock objects, or modifying a table’s dependencies: FactoryLocator::get('Table')->clear(); Configuring provide many commonly used options to find(). This can help with testing as there are fewer methods to mock: // In a controller or table method. $query = $articles->find('all', conditions: ['Articles.created0 码力 | 848 页 | 2.53 MB | 1 年前3
CakePHP Cookbook 4.x
enables services injected with the /development/dependency-injection container to be replaced with mock or stub objects. View • Context classes now include the comment, null, and default metadata options ias, $config) When loading tables from the registry you can customize their dependencies, or use mock objects by providing an $options array: $articles = FactoryLocator::get('Table')->get('Articles' During test cases you may want to flush the registry. Doing so is often useful when you are using mock objects, or modifying a table’s dependencies: FactoryLocator::get('Table')->clear(); Configuring0 码力 | 967 页 | 2.88 MB | 1 年前3
CakePHP Cookbook 3.x
you to create mocks that still execute the original code. This aligns the behavior with how PHPUnit mock objects work. Added EmailTrait to help facilitate testing emails. The default messages for integration ias, $config) When loading tables from the registry you can customize their dependencies, or use mock objects by providing an $options array: // Prior to 3.6 use TableRegistry::get() $articles = Tab During test cases you may want to flush the registry. Doing so is often useful when you are using mock objects, or modifying a table’s dependencies: // Prior to 3.6 use TableRegistry::clear() TableRe0 码力 | 1244 页 | 1.05 MB | 1 年前3
CakePHP Cookbook 3.x
you to create mocks that still execute the original code. This aligns the behavior with how PHPUnit mock objects work. • Added EmailTrait to help facilitate testing emails. • The default messages for integration ias, $config) When loading tables from the registry you can customize their dependencies, or use mock objects by providing an $options array: // Prior to 3.6 use TableRegistry::get() $articles = Tab During test cases you may want to flush the registry. Doing so is often useful when you are using mock objects, or modifying a table’s dependencies: // Prior to 3.6 use TableRegistry::clear() TableRe0 码力 | 967 页 | 2.80 MB | 1 年前3
共 8 条
- 1













