diff --git a/libraries/src/Form/FormField.php b/libraries/src/Form/FormField.php index 2914fb59676cf..eda262c2bd0a8 100644 --- a/libraries/src/Form/FormField.php +++ b/libraries/src/Form/FormField.php @@ -1037,7 +1037,9 @@ protected function getLayoutData() */ protected function getLayoutPaths() { - return array(); + $renderer = new FileLayout('default'); + + return $renderer->getDefaultIncludePaths(); } /** diff --git a/tests/unit/suites/libraries/joomla/form/JFormFieldTest.php b/tests/unit/suites/libraries/joomla/form/JFormFieldTest.php index 463693946ec55..d854a4b47402e 100644 --- a/tests/unit/suites/libraries/joomla/form/JFormFieldTest.php +++ b/tests/unit/suites/libraries/joomla/form/JFormFieldTest.php @@ -71,6 +71,59 @@ protected function tearDown() parent::tearDown(); } + /** + * @test + * + * @return void + */ + public function getLayoutDataReturnsDefaultLayoutPaths() + { + $form = new JFormInspector('form1', array('control' => 'jform')); + + $this->assertThat( + $form->load(JFormDataHelper::$loadFieldDocument), + $this->isTrue(), + 'Line:' . __LINE__ . ' XML string should load successfully.' + ); + + $field = new JFormFieldInspector($form); + + $reflection = new \ReflectionClass($field); + $method = $reflection->getMethod('getLayoutPaths'); + $method->setAccessible(true); + + $layoutPaths = $method->invoke($field); + + $this->assertTrue(is_array($layoutPaths)); + $this->assertTrue(count($layoutPaths) > 0); + } + + /** + * @test + * + * @return void + */ + public function getLayoutPathsCanBeOverriden() + { + $form = new JFormInspector('form1', array('control' => 'jform')); + + JForm::addFieldPath(__DIR__ . '/_testfields'); + + JFormHelper::loadFieldType('customlayouts'); + + $field = new JFormFieldCustomlayouts($form); + + $reflection = new \ReflectionClass($field); + $method = $reflection->getMethod('getLayoutPaths'); + $method->setAccessible(true); + + $layoutPaths = $method->invoke($field); + + $this->assertTrue(is_array($layoutPaths)); + $this->assertTrue(count($layoutPaths) > 0); + $this->assertSame(__DIR__ . DIRECTORY_SEPARATOR . '_testfields', $layoutPaths[0]); + } + /** * Test... * diff --git a/tests/unit/suites/libraries/joomla/form/_testfields/customlayouts.php b/tests/unit/suites/libraries/joomla/form/_testfields/customlayouts.php new file mode 100644 index 0000000000000..9e3e164ad3d78 --- /dev/null +++ b/tests/unit/suites/libraries/joomla/form/_testfields/customlayouts.php @@ -0,0 +1,40 @@ +