Browse Source

Add test for #11620

Ensure that controller names with length equal to the view subDir still
have the subdirectory applied.
Mark Story 8 years ago
parent
commit
7134214693

+ 21 - 0
tests/TestCase/View/ViewTest.php

@@ -676,6 +676,27 @@ class ViewTest extends TestCase
     }
 
     /**
+     * Test getViewFileName applies subdirectories on equal length names
+     *
+     * @return void
+     */
+    public function testGetViewFileNameSubDirLength()
+    {
+        $viewOptions = [
+            'plugin' => null,
+            'name' => 'Jobs',
+            'viewPath' => 'Jobs',
+            'layoutPath' => 'json',
+        ];
+        $view = new TestView(null, null, null, $viewOptions);
+
+        $view->subDir = 'json';
+        $result = $view->getViewFileName('index');
+        $expected = TEST_APP . 'TestApp' . DS . 'Template' . DS . 'Jobs' . DS . 'json' . DS . 'index.ctp';
+        $this->assertPathEquals($expected, $result);
+    }
+
+    /**
      * Test getting layout filenames
      *
      * @return void

+ 2 - 0
tests/test_app/TestApp/Template/Jobs/json/index.ctp

@@ -0,0 +1,2 @@
+<?php
+// used to test subdir path additions.