diff --git a/tests/unit/suites/database/driver/mysql/JDatabaseIteratorMysqlTest.php b/tests/unit/suites/database/driver/mysql/JDatabaseIteratorMysqlTest.php index d44901bd2bf97..6211cdd9e5770 100644 --- a/tests/unit/suites/database/driver/mysql/JDatabaseIteratorMysqlTest.php +++ b/tests/unit/suites/database/driver/mysql/JDatabaseIteratorMysqlTest.php @@ -149,21 +149,18 @@ public function testForEach($select, $from, $column, $class, $limit, $offset, $e public function testCount() { self::$driver->setQuery(self::$driver->getQuery(true)->select('title')->from('#__dbtest')); - $this->assertEquals( - 4, - count(self::$driver->getIterator()) + $this->assertCount( + 4, self::$driver->getIterator() ); self::$driver->setQuery(self::$driver->getQuery(true)->select('title')->from('#__dbtest'), 0, 2); - $this->assertEquals( - 2, - count(self::$driver->getIterator()) + $this->assertCount( + 2, self::$driver->getIterator() ); self::$driver->setQuery(self::$driver->getQuery(true)->select('title')->from('#__dbtest'), 3, 2); - $this->assertEquals( - 1, - count(self::$driver->getIterator()) + $this->assertCount( + 1, self::$driver->getIterator() ); } } diff --git a/tests/unit/suites/database/driver/mysqli/JDatabaseIteratorMysqliTest.php b/tests/unit/suites/database/driver/mysqli/JDatabaseIteratorMysqliTest.php index 28a00c46874b3..9dc34c2edaa55 100644 --- a/tests/unit/suites/database/driver/mysqli/JDatabaseIteratorMysqliTest.php +++ b/tests/unit/suites/database/driver/mysqli/JDatabaseIteratorMysqliTest.php @@ -149,21 +149,18 @@ public function testForEach($select, $from, $column, $class, $limit, $offset, $e public function testCount() { self::$driver->setQuery(self::$driver->getQuery(true)->select('title')->from('#__dbtest')); - $this->assertEquals( - 4, - count(self::$driver->getIterator()) + $this->assertCount( + 4, self::$driver->getIterator() ); self::$driver->setQuery(self::$driver->getQuery(true)->select('title')->from('#__dbtest'), 0, 2); - $this->assertEquals( - 2, - count(self::$driver->getIterator()) + $this->assertCount( + 2, self::$driver->getIterator() ); self::$driver->setQuery(self::$driver->getQuery(true)->select('title')->from('#__dbtest'), 3, 2); - $this->assertEquals( - 1, - count(self::$driver->getIterator()) + $this->assertCount( + 1, self::$driver->getIterator() ); } } diff --git a/tests/unit/suites/libraries/cms/component/router/JComponentRouterBaseTest.php b/tests/unit/suites/libraries/cms/component/router/JComponentRouterBaseTest.php index 215ae6669dfed..acdfa8e83869e 100644 --- a/tests/unit/suites/libraries/cms/component/router/JComponentRouterBaseTest.php +++ b/tests/unit/suites/libraries/cms/component/router/JComponentRouterBaseTest.php @@ -52,7 +52,7 @@ public function testConstruct() $object = new JComponentRouterBaseInspector($app2); $this->assertEquals($app2, $object->app); //The original $app is not the same object as $app2, thus we did not use JFactory - $this->assertFalse($app === $object->app); + $this->assertNotSame($app, $object->app); /** * Test if the setup works when both an app and menu object is handed over diff --git a/tests/unit/suites/libraries/cms/module/JModuleHelperTest.php b/tests/unit/suites/libraries/cms/module/JModuleHelperTest.php index 241e87de8402c..1d2ee0f6e0ef9 100644 --- a/tests/unit/suites/libraries/cms/module/JModuleHelperTest.php +++ b/tests/unit/suites/libraries/cms/module/JModuleHelperTest.php @@ -126,11 +126,7 @@ public function testGetModules() { $modules = JModuleHelper::getModules('position-0'); - $this->assertEquals( - count($modules), - 1, - 'There is 1 module in position-0' - ); + $this->assertCount(1, $modules, 'There is 1 module in position-0'); $this->assertEquals( $modules[0]->id, diff --git a/tests/unit/suites/libraries/cms/plugin/JPluginHelperTest.php b/tests/unit/suites/libraries/cms/plugin/JPluginHelperTest.php index fe51f1b257910..5ef20253d73c9 100644 --- a/tests/unit/suites/libraries/cms/plugin/JPluginHelperTest.php +++ b/tests/unit/suites/libraries/cms/plugin/JPluginHelperTest.php @@ -112,7 +112,7 @@ public function testGetPluginGroup() { $plugins = JPluginHelper::getPlugin('content'); $this->assertInternalType('array', $plugins, 'Method should return all plugins in a group'); - $this->assertEquals(7, count($plugins), 'Method should return all plugins in a group'); + $this->assertCount(7, $plugins, 'Method should return all plugins in a group'); } /** diff --git a/tests/unit/suites/libraries/joomla/application/JApplicationCliTest.php b/tests/unit/suites/libraries/joomla/application/JApplicationCliTest.php index dab66e0f63c2d..e37a1a7a1b323 100644 --- a/tests/unit/suites/libraries/joomla/application/JApplicationCliTest.php +++ b/tests/unit/suites/libraries/joomla/application/JApplicationCliTest.php @@ -138,7 +138,7 @@ public function test__constructDependancyInjection() public function testClose() { // Make sure the application is not already closed. - $this->assertSame($this->class->closed, null); + $this->assertNull($this->class->closed); $this->class->close(3); diff --git a/tests/unit/suites/libraries/joomla/application/JApplicationWebTest.php b/tests/unit/suites/libraries/joomla/application/JApplicationWebTest.php index 45eebdf0b9d69..83435492c3791 100644 --- a/tests/unit/suites/libraries/joomla/application/JApplicationWebTest.php +++ b/tests/unit/suites/libraries/joomla/application/JApplicationWebTest.php @@ -289,7 +289,7 @@ public function testClearHeaders() public function testClose() { // Make sure the application is not already closed. - $this->assertSame($this->class->closed, null); + $this->assertNull($this->class->closed); $this->class->close(3); diff --git a/tests/unit/suites/libraries/joomla/cache/JCacheConstructTest.php b/tests/unit/suites/libraries/joomla/cache/JCacheConstructTest.php index 0e59ee69a5964..91412261bc5aa 100644 --- a/tests/unit/suites/libraries/joomla/cache/JCacheConstructTest.php +++ b/tests/unit/suites/libraries/joomla/cache/JCacheConstructTest.php @@ -45,14 +45,12 @@ public function testConstruct($type) { $class = 'JCacheController' . ucfirst($type); $cache = JCache::getInstance($type); - $this->assertTrue( - ($cache instanceof $class), - 'Expecting= ' . $class . ' Returned= ' . get_class($cache) + $this->assertInstanceOf( + $class, $cache, 'Expecting= ' . $class . ' Returned= ' . get_class($cache) ); $cache2 = JCache::getInstance($type); - $this->assertTrue( - ($cache !== $cache2), - 'Type: ' . $type . ' received the same instance twice' + $this->assertNotSame( + $cache, $cache2, 'Type: ' . $type . ' received the same instance twice' ); } } diff --git a/tests/unit/suites/libraries/joomla/cache/JCacheTest.php b/tests/unit/suites/libraries/joomla/cache/JCacheTest.php index c15a888a8352a..c9655bdf415eb 100644 --- a/tests/unit/suites/libraries/joomla/cache/JCacheTest.php +++ b/tests/unit/suites/libraries/joomla/cache/JCacheTest.php @@ -457,7 +457,7 @@ public function testGc() // Collect Garbage $this->object->gc(); - $this->assertFalse(file_exists($path), "Cache file should not exist."); + $this->assertFileNotExists($path, "Cache file should not exist."); $this->assertFalse($this->object->get(42, '')); diff --git a/tests/unit/suites/libraries/joomla/database/JDatabaseQueryElementTest.php b/tests/unit/suites/libraries/joomla/database/JDatabaseQueryElementTest.php index b95a5553647c7..da739865139ec 100644 --- a/tests/unit/suites/libraries/joomla/database/JDatabaseQueryElementTest.php +++ b/tests/unit/suites/libraries/joomla/database/JDatabaseQueryElementTest.php @@ -244,8 +244,8 @@ public function test__clone_array() $baseElement->testArray[] = 'a'; - $this->assertFalse($baseElement === $cloneElement); - $this->assertEquals(count($cloneElement->testArray), 0); + $this->assertNotSame($baseElement, $cloneElement); + $this->assertCount(0, $cloneElement->testArray); } /** @@ -263,7 +263,7 @@ public function test__clone_object() $cloneElement = clone($baseElement); - $this->assertFalse($baseElement === $cloneElement); - $this->assertFalse($baseElement->testObject === $cloneElement->testObject); + $this->assertNotSame($baseElement, $cloneElement); + $this->assertNotSame($baseElement->testObject, $cloneElement->testObject); } } diff --git a/tests/unit/suites/libraries/joomla/database/JDatabaseQueryTest.php b/tests/unit/suites/libraries/joomla/database/JDatabaseQueryTest.php index 94f9d843f6cbf..91e5cce42b087 100644 --- a/tests/unit/suites/libraries/joomla/database/JDatabaseQueryTest.php +++ b/tests/unit/suites/libraries/joomla/database/JDatabaseQueryTest.php @@ -1642,8 +1642,8 @@ public function test__clone_array() $baseElement->testArray[] = 'test'; - $this->assertFalse($baseElement === $cloneElement); - $this->assertTrue(count($cloneElement->testArray) == 0); + $this->assertNotSame($baseElement, $cloneElement); + $this->assertCount(0, $cloneElement->testArray); } /** @@ -1661,9 +1661,9 @@ public function test__clone_object() $cloneElement = clone($baseElement); - $this->assertFalse($baseElement === $cloneElement); + $this->assertNotSame($baseElement, $cloneElement); - $this->assertFalse($baseElement->testObject === $cloneElement->testObject); + $this->assertNotSame($baseElement->testObject, $cloneElement->testObject); } /** diff --git a/tests/unit/suites/libraries/joomla/feed/JFeedEntryTest.php b/tests/unit/suites/libraries/joomla/feed/JFeedEntryTest.php index 25728cb7b66f3..fd853d46ccd60 100644 --- a/tests/unit/suites/libraries/joomla/feed/JFeedEntryTest.php +++ b/tests/unit/suites/libraries/joomla/feed/JFeedEntryTest.php @@ -83,7 +83,7 @@ public function testMagicSetUpdatedDateJDateObject() $properties = TestReflection::getValue($this->_instance, 'properties'); $this->assertInstanceOf('JDate', $properties['updatedDate']); - $this->assertTrue($date === $properties['updatedDate']); + $this->assertSame($date, $properties['updatedDate']); } /** @@ -102,7 +102,7 @@ public function testMagicSetAuthorWithPerson() $properties = TestReflection::getValue($this->_instance, 'properties'); $this->assertInstanceOf('JFeedPerson', $properties['author']); - $this->assertTrue($person === $properties['author']); + $this->assertSame($person, $properties['author']); } /** @@ -202,7 +202,7 @@ public function testAddContributor() $properties = TestReflection::getValue($this->_instance, 'properties'); // Make sure we aren't adding the same contributor more than once. - $this->assertTrue(count($properties['contributors']) == 1); + $this->assertCount(1, $properties['contributors']); } /** @@ -232,7 +232,7 @@ public function testAddLink() $properties = TestReflection::getValue($this->_instance, 'properties'); // Make sure we aren't adding the same link more than once. - $this->assertTrue(count($properties['links']) == 1); + $this->assertCount(1, $properties['links']); } /** diff --git a/tests/unit/suites/libraries/joomla/feed/JFeedTest.php b/tests/unit/suites/libraries/joomla/feed/JFeedTest.php index a1c1495e6f816..29ba1a662b49f 100644 --- a/tests/unit/suites/libraries/joomla/feed/JFeedTest.php +++ b/tests/unit/suites/libraries/joomla/feed/JFeedTest.php @@ -83,7 +83,7 @@ public function testMagicSetUpdatedDateJDateObject() $properties = TestReflection::getValue($this->_instance, 'properties'); $this->assertInstanceOf('JDate', $properties['updatedDate']); - $this->assertTrue($date === $properties['updatedDate']); + $this->assertSame($date, $properties['updatedDate']); } /** @@ -102,7 +102,7 @@ public function testMagicSetAuthorWithPerson() $properties = TestReflection::getValue($this->_instance, 'properties'); $this->assertInstanceOf('JFeedPerson', $properties['author']); - $this->assertTrue($person === $properties['author']); + $this->assertSame($person, $properties['author']); } /** @@ -189,7 +189,7 @@ public function testAddContributor() $properties = TestReflection::getValue($this->_instance, 'properties'); // Make sure we aren't adding the same contributor more than once. - $this->assertTrue(count($properties['contributors']) == 1); + $this->assertCount(1, $properties['contributors']); } /** @@ -217,7 +217,7 @@ public function testAddEntry() $entries = TestReflection::getValue($this->_instance, 'entries'); // Make sure we aren't adding the same entry more than once. - $this->assertTrue(count($entries) == 1); + $this->assertCount(1, $entries); } /** diff --git a/tests/unit/suites/libraries/joomla/feed/parser/JFeedParserRssTest.php b/tests/unit/suites/libraries/joomla/feed/parser/JFeedParserRssTest.php index 6f7c880856f39..21c77996f3419 100644 --- a/tests/unit/suites/libraries/joomla/feed/parser/JFeedParserRssTest.php +++ b/tests/unit/suites/libraries/joomla/feed/parser/JFeedParserRssTest.php @@ -506,19 +506,19 @@ public function testProcessFeedEntry() TestReflection::invoke($this->_instance, 'processFeedEntry', $entry, $el); - $this->assertEquals('http://example.com/id', $entry->uri); - $this->assertEquals('title', $entry->title); + $this->assertSame('http://example.com/id', $entry->uri); + $this->assertSame('title', $entry->title); $this->assertInstanceOf('JDate', $entry->updatedDate); $this->assertInstanceOf('JDate', $entry->publishedDate); - $this->assertEquals('description', $entry->content); - $this->assertEquals(array('category' => ''), $entry->categories); + $this->assertSame('description', $entry->content); + $this->assertSame(array('category' => ''), $entry->categories); $this->assertInstanceOf('JFeedPerson', $entry->author); - $this->assertEquals('Webmaster', $entry->author->name); - $this->assertEquals('admin@domain.com', $entry->author->email); - $this->assertEquals(1, count($entry->links)); + $this->assertSame('Webmaster', $entry->author->name); + $this->assertSame('admin@domain.com', $entry->author->email); + $this->assertCount(1, $entry->links); $this->assertInstanceOf('JFeedLink', $entry->links[0]); - $this->assertEquals('http://www.w3schools.com/media/3d.wmv', $entry->links[0]->uri); - $this->assertEquals('video/wmv', $entry->links[0]->type); + $this->assertSame('http://www.w3schools.com/media/3d.wmv', $entry->links[0]->uri); + $this->assertSame('video/wmv', $entry->links[0]->type); $this->assertEquals(78645, $entry->links[0]->length); } @@ -540,8 +540,8 @@ public function testProcessPerson($input, $name, $email) $this->assertInstanceOf('JFeedPerson', $person); - $this->assertEquals($name, $person->name); - $this->assertEquals($email, $person->email); + $this->assertSame($name, $person->name); + $this->assertSame($email, $person->email); } /** diff --git a/tests/unit/suites/libraries/joomla/google/JGoogleDataPicasaAlbumTest.php b/tests/unit/suites/libraries/joomla/google/JGoogleDataPicasaAlbumTest.php index 1cd9e13b4c8bc..3269464f743c9 100644 --- a/tests/unit/suites/libraries/joomla/google/JGoogleDataPicasaAlbumTest.php +++ b/tests/unit/suites/libraries/joomla/google/JGoogleDataPicasaAlbumTest.php @@ -324,7 +324,7 @@ public function testListPhotos() $this->http->expects($this->once())->method('get')->will($this->returnCallback('picasaPhotolistCallback')); $results = $this->object->listPhotos(); - $this->assertEquals(count($results), 2); + $this->assertCount(2, $results); $i = 1; foreach ($results as $result) diff --git a/tests/unit/suites/libraries/joomla/google/JGoogleDataPicasaTest.php b/tests/unit/suites/libraries/joomla/google/JGoogleDataPicasaTest.php index 2745c47c8e0e2..d77a7cfe22224 100644 --- a/tests/unit/suites/libraries/joomla/google/JGoogleDataPicasaTest.php +++ b/tests/unit/suites/libraries/joomla/google/JGoogleDataPicasaTest.php @@ -144,7 +144,7 @@ public function testListAlbums() $this->http->expects($this->once())->method('get')->will($this->returnCallback('picasaAlbumlistCallback')); $results = $this->object->listAlbums('userID'); - $this->assertEquals(count($results), 2); + $this->assertCount(2, $results); $i = 1; foreach ($results as $result) diff --git a/tests/unit/suites/libraries/joomla/image/JImageTest.php b/tests/unit/suites/libraries/joomla/image/JImageTest.php index 88e78997efbbf..8c8b5d2dddd97 100644 --- a/tests/unit/suites/libraries/joomla/image/JImageTest.php +++ b/tests/unit/suites/libraries/joomla/image/JImageTest.php @@ -367,15 +367,15 @@ public function testToFileGif() $b = JImage::getImageFileProperties($outFileGif); // Assert that properties that should be equal are equal. - $this->assertTrue($a->width == $b->width); - $this->assertTrue($a->height == $b->height); - $this->assertTrue($a->attributes == $b->attributes); - $this->assertTrue($a->bits == $b->bits); - $this->assertTrue($a->channels == $b->channels); + $this->assertSame($a->width, $b->width); + $this->assertSame($a->height, $b->height); + $this->assertSame($a->attributes, $b->attributes); + $this->assertSame($a->bits, $b->bits); + $this->assertSame($a->channels, $b->channels); // Assert that the properties that should be different are different. - $this->assertTrue($b->mime == 'image/gif'); - $this->assertTrue($b->type == IMAGETYPE_GIF); + $this->assertSame($b->mime, 'image/gif'); + $this->assertEquals($b->type, IMAGETYPE_GIF); // Clean up after ourselves. unlink($outFileGif); @@ -402,15 +402,15 @@ public function testToFilePng() $b = JImage::getImageFileProperties($outFilePng); // Assert that properties that should be equal are equal. - $this->assertTrue($a->width == $b->width); - $this->assertTrue($a->height == $b->height); - $this->assertTrue($a->attributes == $b->attributes); - $this->assertTrue($a->bits == $b->bits); + $this->assertSame($a->width, $b->width); + $this->assertSame($a->height, $b->height); + $this->assertSame($a->attributes, $b->attributes); + $this->assertSame($a->bits, $b->bits); // Assert that the properties that should be different are different. - $this->assertTrue($b->mime == 'image/png'); - $this->assertTrue($b->type == IMAGETYPE_PNG); - $this->assertTrue($b->channels == null); + $this->assertSame($b->mime, 'image/png'); + $this->assertEquals($b->type, IMAGETYPE_PNG); + $this->assertNull($b->channels); // Clean up after ourselves. unlink($outFilePng); @@ -439,13 +439,13 @@ public function testToFileJpg() $b = JImage::getImageFileProperties($outFileJpg); // Assert that properties that should be equal are equal. - $this->assertTrue($a->width == $b->width); - $this->assertTrue($a->height == $b->height); - $this->assertTrue($a->attributes == $b->attributes); - $this->assertTrue($a->bits == $b->bits); - $this->assertTrue($a->mime == $b->mime); - $this->assertTrue($a->type == $b->type); - $this->assertTrue($a->channels == $b->channels); + $this->assertSame($a->width, $b->width); + $this->assertSame($a->height, $b->height); + $this->assertSame($a->attributes, $b->attributes); + $this->assertSame($a->bits, $b->bits); + $this->assertSame($a->mime, $b->mime); + $this->assertSame($a->type, $b->type); + $this->assertSame($a->channels, $b->channels); // Clean up after ourselves. unlink($outFileJpg); @@ -474,13 +474,13 @@ public function testToFileDefault() $b = JImage::getImageFileProperties($outFileDefault); // Assert that properties that should be equal are equal. - $this->assertTrue($a->width == $b->width); - $this->assertTrue($a->height == $b->height); - $this->assertTrue($a->attributes == $b->attributes); - $this->assertTrue($a->bits == $b->bits); - $this->assertTrue($a->mime == $b->mime); - $this->assertTrue($a->type == $b->type); - $this->assertTrue($a->channels == $b->channels); + $this->assertSame($a->width, $b->width); + $this->assertSame($a->height, $b->height); + $this->assertSame($a->attributes, $b->attributes); + $this->assertSame($a->bits, $b->bits); + $this->assertSame($a->mime, $b->mime); + $this->assertSame($a->type, $b->type); + $this->assertSame($a->channels, $b->channels); // Clean up after ourselves. unlink($outFileDefault); @@ -520,7 +520,7 @@ public function testGetHeight() // Create a new JImageInspector object from the image handle. $image = new JImageInspector($imageHandle); - $this->assertTrue(($image->getHeight() == 42), 'Line: ' . __LINE__); + $this->assertSame($image->getHeight(), 42, 'Line: ' . __LINE__); } /** @@ -555,7 +555,7 @@ public function testGetWidth() // Create a new JImageInspector object from the image handle. $image = new JImageInspector($imageHandle); - $this->assertTrue(($image->getWidth() == 108), 'Line: ' . __LINE__); + $this->assertSame($image->getWidth(), 108, 'Line: ' . __LINE__); } /** diff --git a/tests/unit/suites/libraries/joomla/keychain/JKeychainTest.php b/tests/unit/suites/libraries/joomla/keychain/JKeychainTest.php index d203c64e6f6cd..2fe86de8e4861 100644 --- a/tests/unit/suites/libraries/joomla/keychain/JKeychainTest.php +++ b/tests/unit/suites/libraries/joomla/keychain/JKeychainTest.php @@ -83,7 +83,7 @@ public function testCreatePassphraseFile() $keychain = new JKeychain; $keychain->createPassphraseFile('testpassphrase', $passphraseFile, $privateKeyFile, 'password'); - $this->assertTrue(file_exists($passphraseFile), 'Test passphrase file exists'); + $this->assertFileExists($passphraseFile, 'Test passphrase file exists'); } /** @@ -147,7 +147,7 @@ public function testSaveKeychain() $keychain->set('dennis', 'liao'); $this->assertTrue((bool) $keychain->saveKeychain($keychainFile, $passphraseFile, $publicKeyFile), 'Assert that saveKeychain returns true.'); - $this->assertTrue(file_exists($keychainFile), 'Check that keychain file was created properly.'); + $this->assertFileExists($keychainFile, 'Check that keychain file was created properly.'); } /** diff --git a/tests/unit/suites/libraries/joomla/log/loggers/JLogLoggerDatabaseTest.php b/tests/unit/suites/libraries/joomla/log/loggers/JLogLoggerDatabaseTest.php index 26ad6a58f04f2..acf7a6d41c15a 100644 --- a/tests/unit/suites/libraries/joomla/log/loggers/JLogLoggerDatabaseTest.php +++ b/tests/unit/suites/libraries/joomla/log/loggers/JLogLoggerDatabaseTest.php @@ -123,7 +123,7 @@ public function testConnect01() $logger = new JLogLoggerDatabaseInspector($config); $logger->connect(); - $this->assertTrue($logger->db instanceof JDatabaseDriver, 'Line: ' . __LINE__); + $this->assertInstanceOf('\\JDatabaseDriver', $logger->db, 'Line: ' . __LINE__); } /** diff --git a/tests/unit/suites/libraries/joomla/table/JTableNestedTest.php b/tests/unit/suites/libraries/joomla/table/JTableNestedTest.php index 0258ed457ffb8..b9c75e54169b1 100644 --- a/tests/unit/suites/libraries/joomla/table/JTableNestedTest.php +++ b/tests/unit/suites/libraries/joomla/table/JTableNestedTest.php @@ -82,7 +82,7 @@ public function testDelete() $ids = self::$driver->setQuery('SELECT id FROM #__categories')->loadColumn(); - $this->assertEquals(4, count($ids), 'Checks 3 nodes were deleted.'); + $this->assertCount(4, $ids, 'Checks 3 nodes were deleted.'); $this->assertArrayNotHasKey(103, $ids, 'Checks node 103 was deleted.'); $this->assertArrayNotHasKey(203, $ids, 'Checks node 203 was deleted.'); $this->assertArrayNotHasKey(204, $ids, 'Checks node 204 was deleted.'); diff --git a/tests/unit/suites/libraries/joomla/user/JUserHelperTest.php b/tests/unit/suites/libraries/joomla/user/JUserHelperTest.php index 0ae76af60e2db..896c674fe5468 100644 --- a/tests/unit/suites/libraries/joomla/user/JUserHelperTest.php +++ b/tests/unit/suites/libraries/joomla/user/JUserHelperTest.php @@ -407,9 +407,8 @@ public function testGetCryptedPassword() 'Plain text password is returned' ); - $this->assertTrue( - strlen(JUserHelper::getCryptedPassword('mySuperSecretPassword', '', 'crypt')) === 13, - 'Password is hashed to crypt without salt' + $this->assertSame( + strlen(JUserHelper::getCryptedPassword('mySuperSecretPassword', '', 'crypt')), 13, 'Password is hashed to crypt without salt' ); $password = JUserHelper::getCryptedPassword('mySuperSecretPassword', '{crypt}myA38Ex7aHbws', 'crypt'); @@ -422,9 +421,8 @@ public function testGetCryptedPassword() $this->assertSame('{crypt}myA38Ex7aHbws', $password, 'Password is hashed to crypt with salt with encryption prefix'); $this->assertSame('my', substr($password, 7, 2), 'Password hash uses expected salt'); - $this->assertTrue( - strlen(JUserHelper::getCryptedPassword('mySuperSecretPassword', '', 'crypt-des')) === 13, - 'Password is hashed to crypt-des without salt' + $this->assertSame( + strlen(JUserHelper::getCryptedPassword('mySuperSecretPassword', '', 'crypt-des')), 13, 'Password is hashed to crypt-des without salt' ); $password = JUserHelper::getCryptedPassword('mySuperSecretPassword', '{crypt}myA38Ex7aHbws', 'crypt-des'); @@ -437,9 +435,8 @@ public function testGetCryptedPassword() $this->assertSame('{crypt}myA38Ex7aHbws', $password, 'Password is hashed to crypt-des with salt with encryption prefix'); $this->assertSame('my', substr($password, 7, 2), 'Password hash uses expected salt'); - $this->assertTrue( - strlen(JUserHelper::getCryptedPassword('mySuperSecretPassword', '', 'crypt-md5')) === 34, - 'Password is hashed to crypt-md5 without salt' + $this->assertSame( + strlen(JUserHelper::getCryptedPassword('mySuperSecretPassword', '', 'crypt-md5')), 34, 'Password is hashed to crypt-md5 without salt' ); $password = JUserHelper::getCryptedPassword('mySuperSecretPassword', '{crypt}myA38Ex7aHbws', 'crypt-md5'); @@ -452,9 +449,8 @@ public function testGetCryptedPassword() $this->assertSame('{crypt}myA38Ex7aHbws', $password, 'Password is hashed to crypt-md5 with salt with encryption prefix'); $this->assertSame('my', substr($password, 7, 2), 'Password hash uses expected salt'); - $this->assertTrue( - strlen(JUserHelper::getCryptedPassword('mySuperSecretPassword', '', 'crypt-blowfish')) === 60, - 'Password is hashed to crypt-blowfish without salt' + $this->assertSame( + strlen(JUserHelper::getCryptedPassword('mySuperSecretPassword', '', 'crypt-blowfish')), 60, 'Password is hashed to crypt-blowfish without salt' ); $password = JUserHelper::getCryptedPassword('mySuperSecretPassword', '{crypt}myA38Ex7aHbws', 'crypt-blowfish'); @@ -469,7 +465,7 @@ public function testGetCryptedPassword() $password = JUserHelper::getCryptedPassword('mySuperSecretPassword', '', 'aprmd5'); - $this->assertTrue(strlen($password) === 37, 'Password is hashed to APRMD5 without salt'); + $this->assertSame(strlen($password), 37, 'Password is hashed to APRMD5 without salt'); $this->assertSame('$apr1$', substr($password, 0, 6), 'Password hash uses expected prefix'); $this->assertSame( @@ -479,9 +475,8 @@ public function testGetCryptedPassword() ); // Length should be 81 characters but due to a bug which causes the prefix to always render it adds 8 characters - $this->assertTrue( - strlen(JUserHelper::getCryptedPassword('mySuperSecretPassword', '', 'sha256')) === 89, - 'Password is hashed to SHA256 without salt' + $this->assertSame( + strlen(JUserHelper::getCryptedPassword('mySuperSecretPassword', '', 'sha256')), 89, 'Password is hashed to SHA256 without salt' ); // Due to a bug which causes the prefix to always render it is present here @@ -555,9 +550,8 @@ public function testGetCryptedPasswordWithMhash() 'Password is hashed to MD5-BASE64 with encryption prefix' ); - $this->assertTrue( - strlen(JUserHelper::getCryptedPassword('mySuperSecretPassword', '', 'ssha')) === 32, - 'Password is hashed to SSHA without salt' + $this->assertSame( + strlen(JUserHelper::getCryptedPassword('mySuperSecretPassword', '', 'ssha')), 32, 'Password is hashed to SSHA without salt' ); $this->assertSame( @@ -572,9 +566,8 @@ public function testGetCryptedPasswordWithMhash() 'Password is hashed to SSHA with salt with encryption prefix' ); - $this->assertTrue( - strlen(JUserHelper::getCryptedPassword('mySuperSecretPassword', '', 'smd5')) === 28, - 'Password is hashed to SMD5 without salt' + $this->assertSame( + strlen(JUserHelper::getCryptedPassword('mySuperSecretPassword', '', 'smd5')), 28, 'Password is hashed to SMD5 without salt' ); $this->assertSame( diff --git a/tests/unit/suites/libraries/legacy/model/JModelLegacyTest.php b/tests/unit/suites/libraries/legacy/model/JModelLegacyTest.php index fc74f96ebc775..b86edb422f14d 100644 --- a/tests/unit/suites/libraries/legacy/model/JModelLegacyTest.php +++ b/tests/unit/suites/libraries/legacy/model/JModelLegacyTest.php @@ -210,7 +210,7 @@ public function testThatAnExecptionIsThrownWhenNoModelIsInTheName() */ public function testReturningAnInstanceOfAnExistingClassWorks() { - $this->assertTrue($this->fixture instanceof TestModelLead); + $this->assertInstanceOf('\\TestModelLead', $this->fixture); } /** @@ -288,7 +288,7 @@ public function testGetStateSetsInternalStatesetFlag() { $this->fixture->getState(); $stateSet = TestReflection::getValue($this->fixture, '__state_set'); - $this->assertTrue($stateSet === true); + $this->assertTrue($stateSet); } /** @@ -348,7 +348,7 @@ public function testGetThatDboReturnsCorrectObject() public function testSetDbo() { $this->fixture->setDbo(new stdClass); - $this->assertTrue($this->fixture->getDbo() instanceof stdClass); + $this->assertInstanceOf('\\stdClass', $this->fixture->getDbo()); } /** diff --git a/tests/unit/suites/libraries/legacy/model/JModelListTest.php b/tests/unit/suites/libraries/legacy/model/JModelListTest.php index 0c8d22d358d97..56b3dd0046b45 100644 --- a/tests/unit/suites/libraries/legacy/model/JModelListTest.php +++ b/tests/unit/suites/libraries/legacy/model/JModelListTest.php @@ -438,7 +438,7 @@ public function testGetItemsReturnsFalseOnDatabaseException() TestReflection::setValue($object, '__state_set', true); - $this->assertSame(false, $object->getItems()); + $this->assertFalse($object->getItems()); } /**