americanreading / view-mock
Test double for View
v1.0.1
2018-05-23 14:12 UTC
Requires
This package is auto-updated.
Last update: 2025-03-24 06:12:36 UTC
README
This library provides the ViewDouble
mock implementation of View
for use in automated tests.
To use, add as a dev requirement for Composer:
{
"require-dev": {
"phpunit/phpunit": "^7",
"americanreading/view-mock": "^1"
}
}
When using this mock, you can pre-set the output the View will render by passing a string to the constructor or setting the public output
property.
To assert the view as rendered, inspect the instance's context
property.
$view = new ViewDouble('PRE-SET OUTPUT');
// Do stuff that should call render()...
$this->assertEquals(
'Expected value passed in the context',
$view->context['item']);