Skip to content

Commit

Permalink
Add test for setting view theme to vendor namespaced plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Jun 3, 2014
1 parent 305f316 commit 641b6a1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
31 changes: 23 additions & 8 deletions tests/TestCase/View/ViewTest.php
Expand Up @@ -101,8 +101,8 @@ class TestThemeView extends View {
/**
* renderElement method
*
* @param string $name
* @param array $params
* @param string $name Element name.
* @param array $params Params list.
* @return string The given name
*/
public function renderElement($name, $params = array()) {
Expand Down Expand Up @@ -195,7 +195,7 @@ class TestBeforeAfterHelper extends Helper {
/**
* beforeLayout method
*
* @param string $viewFile
* @param string $viewFile View file name.
* @return void
*/
public function beforeLayout($viewFile) {
Expand All @@ -205,7 +205,7 @@ public function beforeLayout($viewFile) {
/**
* afterLayout method
*
* @param string $layoutFile
* @param string $layoutFile Layout file name.
* @return void
*/
public function afterLayout($layoutFile) {
Expand All @@ -221,6 +221,11 @@ public function afterLayout($layoutFile) {
*/
class TestObjectWithToString {

/**
* Return string value.
*
* @return string
*/
public function __toString() {
return "I'm ObjectWithToString";
}
Expand Down Expand Up @@ -272,7 +277,7 @@ public function setUp() {

App::objects('Plugin', null, false);

Plugin::load(array('TestPlugin', 'TestPlugin', 'PluginJs', 'TestTheme'));
Plugin::load(['TestPlugin', 'PluginJs', 'TestTheme', 'Company/TestPluginThree']);
Configure::write('debug', true);
}

Expand Down Expand Up @@ -301,7 +306,8 @@ public function testGetTemplate() {
$request = $this->getMock('Cake\Network\Request');
$response = $this->getMock('Cake\Network\Response');

$viewOptions = [ 'plugin' => null,
$viewOptions = [
'plugin' => null,
'name' => 'Pages',
'viewPath' => 'Pages'
];
Expand Down Expand Up @@ -331,6 +337,13 @@ public function testGetTemplate() {
$expected = TEST_APP . 'TestApp' . DS . 'Template' . DS . 'Layout' . DS . 'Email' . DS . 'html' . DS . 'default.ctp';
$result = $ThemeView->getLayoutFileName();
$this->assertPathEquals($expected, $result);

$ThemeView = new TestThemeView(null, null, null, $viewOptions);

$ThemeView->theme = 'Company/TestPluginThree';
$expected = Plugin::path('Company/TestPluginThree') . 'Template' . DS . 'Layout' . DS . 'default.ctp';
$result = $ThemeView->getLayoutFileName();
$this->assertPathEquals($expected, $result);
}

/**
Expand Down Expand Up @@ -1279,8 +1292,9 @@ public static function blockValueProvider() {
/**
* Test appending to a block with append.
*
* @dataProvider blockValueProvider
* @param mixed $value Value
* @return void
* @dataProvider blockValueProvider
*/
public function testBlockAppend($value) {
$this->View->assign('testBlock', 'Block');
Expand Down Expand Up @@ -1308,8 +1322,9 @@ public function testBlockAppendObjectWithoutToString() {
/**
* Test prepending to a block with prepend.
*
* @dataProvider blockValueProvider
* @param mixed $value Value
* @return void
* @dataProvider blockValueProvider
*/
public function testBlockPrepend($value) {
$this->View->assign('test', 'Block');
Expand Down
@@ -0,0 +1,2 @@
default test_three_theme layout
<?= $this->fetch('content') ?>

0 comments on commit 641b6a1

Please sign in to comment.