diff --git a/tests/unit/suites/libraries/cms/component/JComponentHelperTest.php b/tests/unit/suites/libraries/cms/component/JComponentHelperTest.php index fe5878a76f880..a559beb353ed2 100644 --- a/tests/unit/suites/libraries/cms/component/JComponentHelperTest.php +++ b/tests/unit/suites/libraries/cms/component/JComponentHelperTest.php @@ -38,16 +38,49 @@ protected function getDataSet() * @return void * * @since 3.2 + * @covers JComponentHelper::getComponent */ public function testGetComponent() { $component = JComponentHelper::getComponent('com_content'); - $this->assertEquals( - $component->id, - 22, - 'com_content is extension ID 22' - ); + $this->assertEquals(22, $component->id, 'com_content is extension ID 22'); + $this->assertInstanceOf('JRegistry', $component->params, 'Parameters need to be of type JRegistry'); + $this->assertEquals('1', $component->params->get('show_title'), 'The show_title parameter of com_content should be set to 1'); + $this->assertObjectHasAttribute('enabled', $component, 'The component data needs to have an enabled field'); + $this->assertSame($component, JComponentHelper::getComponent('com_content'), 'The object returned must always be the same'); + } + + /** + * Test JComponentHelper::getComponent + * + * @return void + * + * @since 3.4 + * @covers JComponentHelper::getComponent + */ + public function testGetComponent_falseComponent() + { + $component = JComponentHelper::getComponent('com_false'); + $this->assertObjectNotHasAttribute('id', $component, 'Anonymous component does not have an ID'); + $this->assertInstanceOf('JRegistry', $component->params, 'Parameters need to be of type JRegistry'); + $this->assertEquals(0, $component->params->count(), 'Anonymous component does not have any set parameters'); + $this->assertObjectHasAttribute('enabled', $component, 'The component data needs to have an enabled field'); + $this->assertTrue($component->enabled, 'The anonymous component has to be enabled by default if not strict'); + } + + /** + * Test JComponentHelper::getComponent + * + * @return void + * + * @since 3.4 + * @covers JComponentHelper::getComponent + */ + public function testGetComponent_falseComponent_strict() + { + $component = JComponentHelper::getComponent('com_false', true); + $this->assertFalse($component->enabled, 'The anonymous component has to be disabled by default if strict'); } /** @@ -56,6 +89,7 @@ public function testGetComponent() * @return void * * @since 3.2 + * @covers JComponentHelper::isEnabled */ public function testIsEnabled() { @@ -71,6 +105,7 @@ public function testIsEnabled() * @return void * * @since 3.4 + * @covers JComponentHelper::isInstalled */ public function testIsInstalled() { @@ -89,6 +124,7 @@ public function testIsInstalled() * Test JComponentHelper::getParams * * @return void + * @covers JComponentHelper::getParams */ public function testGetParams() {