diff --git a/tests/unit/suites/libraries/cms/installer/JInstallerTest.php b/tests/unit/suites/libraries/cms/installer/JInstallerTest.php
index f77768cb81a75..bc84a9743b5f2 100644
--- a/tests/unit/suites/libraries/cms/installer/JInstallerTest.php
+++ b/tests/unit/suites/libraries/cms/installer/JInstallerTest.php
@@ -31,22 +31,7 @@ protected function setUp()
{
parent::setUp();
- $this->saveFactoryState();
-
- $this->object = JInstaller::getInstance();
- }
-
- /**
- * Tears down the fixture, for example, closes a network connection.
- * This method is called after a test is executed.
- *
- * @return void
- */
- protected function tearDown()
- {
- $this->restoreFactoryState();
-
- parent::tearDown();
+ $this->object = new JInstaller;
}
/**
@@ -72,10 +57,16 @@ protected function getDataSet()
*/
public function testGetInstance()
{
- $this->assertThat(
- $this->object = JInstaller::getInstance(),
- $this->isInstanceOf('JInstaller'),
- 'JInstaller::getInstance failed'
+ $object1 = JInstaller::getInstance();
+
+ $this->assertInstanceOf(
+ 'JInstaller',
+ $object1
+ );
+
+ $this->assertSame(
+ $object1,
+ JInstaller::getInstance()
);
}
@@ -91,21 +82,18 @@ public function testIsAndSetOverwrite()
{
$this->object->setOverwrite(false);
- $this->assertThat(
+ $this->assertFalse(
$this->object->isOverwrite(),
- $this->equalTo(false),
'Get or Set overwrite failed'
);
- $this->assertThat(
+ $this->assertFalse(
$this->object->setOverwrite(true),
- $this->equalTo(false),
'setOverwrite did not return the old value properly.'
);
- $this->assertThat(
+ $this->assertTrue(
$this->object->isOverwrite(),
- $this->equalTo(true),
'getOverwrite did not return the expected value.'
);
}
@@ -122,9 +110,9 @@ public function testGetAndSetRedirectUrl()
{
$this->object->setRedirectUrl('http://www.example.com');
- $this->assertThat(
+ $this->assertEquals(
$this->object->getRedirectUrl(),
- $this->equalTo('http://www.example.com'),
+ 'http://www.example.com',
'Get or Set Redirect Url failed'
);
}
@@ -141,21 +129,18 @@ public function testIsAndSetUpgrade()
{
$this->object->setUpgrade(false);
- $this->assertThat(
+ $this->assertFalse(
$this->object->isUpgrade(),
- $this->equalTo(false),
'Get or Set Upgrade failed'
);
- $this->assertThat(
+ $this->assertFalse(
$this->object->setUpgrade(true),
- $this->equalTo(false),
'setUpgrade did not return the old value properly.'
);
- $this->assertThat(
+ $this->assertTrue(
$this->object->isUpgrade(),
- $this->equalTo(true),
'getUpgrade did not return the expected value.'
);
}
@@ -169,17 +154,17 @@ public function testIsAndSetUpgrade()
*/
public function testGetPath()
{
- $this->assertThat(
+ $this->assertEquals(
$this->object->getPath('path1_getpath', 'default_value'),
- $this->equalTo('default_value'),
+ 'default_value',
'getPath did not return the default value for an undefined path'
);
$this->object->setPath('path2_getpath', JPATH_BASE . '/required_path');
- $this->assertThat(
+ $this->assertEquals(
$this->object->getPath('path2_getpath', 'default_value'),
- $this->equalTo(JPATH_BASE . '/required_path'),
+ JPATH_BASE . '/required_path',
'getPath did not return the previously set value for the path'
);
}
@@ -195,9 +180,8 @@ public function testAbortQuery()
{
$this->object->pushStep(array('type' => 'query'));
- $this->assertThat(
- $this->object->abort(),
- $this->isFalse()
+ $this->assertFalse(
+ $this->object->abort()
);
}
@@ -221,9 +205,8 @@ public function testAbortDefault()
$this->object->pushStep(array('type' => 'testtype'));
- $this->assertThat(
- $this->object->abort(null, 'testadapter'),
- $this->isTrue()
+ $this->assertTrue(
+ $this->object->abort(null, 'testadapter')
);
}
@@ -238,9 +221,38 @@ public function testAbortBadType()
{
$this->object->pushStep(array('type' => 'badstep'));
- $this->assertThat(
- $this->object->abort(null, false),
- $this->isFalse()
+ $this->assertFalse(
+ $this->object->abort(null, false)
+ );
+ }
+
+ /**
+ * @testdox Ensure parseLanguages() returns 0 when there are no children in the language tag
+ *
+ * @covers JInstaller::parseLanguages
+ */
+ public function testParseLanguagesWithNoChildren()
+ {
+ $emptyXml = new SimpleXMLElement('');
+
+ $this->assertEquals(
+ 0,
+ $this->object->parseLanguages($emptyXml)
+ );
+ }
+
+ /**
+ * @testdox Ensure parseFiles() returns 0 when there are no children in the files tag
+ *
+ * @covers JInstaller::parseFiles
+ */
+ public function testParseFilesWithNoChildren()
+ {
+ $emptyXml = new SimpleXMLElement('');
+
+ $this->assertEquals(
+ 0,
+ $this->object->parseFiles($emptyXml)
);
}
@@ -256,16 +268,16 @@ public function testParseXMLInstallFile()
$xml = JInstaller::parseXMLInstallFile(__DIR__ . '/data/pkg_joomla.xml');
// Verify the method returns an array of data
- $this->assertThat(
+ $this->assertInternalType(
+ 'array',
$xml,
- $this->isType('array'),
'Ensure JInstaller::parseXMLInstallFile returns an array'
);
// Verify the version string in the $xml object matches that from the XML file
- $this->assertThat(
+ $this->assertEquals(
$xml['version'],
- $this->equalTo('2.5.0'),
+ '2.5.0',
'The version string should be 2.5.0 as specified in the parsed XML file'
);
}
@@ -279,9 +291,9 @@ public function testParseXMLInstallFile()
*/
public function testIsManifest()
{
- $this->assertThat(
+ $this->assertInstanceOf(
+ 'SimpleXmlElement',
$this->object->isManifest(__DIR__ . '/data/pkg_joomla.xml'),
- $this->isInstanceOf('SimpleXmlElement'),
'Ensure JInstaller::isManifest properly tests a valid manifest file'
);
}