From 3cca17440e21b2931e7897e0fd59988a66b30f81 Mon Sep 17 00:00:00 2001 From: Frank Mayer Date: Thu, 29 Dec 2016 16:30:46 +0200 Subject: [PATCH 1/4] Remove identical method override --- .../joomla/cache/storage/JCacheStorageMock.php | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/tests/unit/suites/libraries/joomla/cache/storage/JCacheStorageMock.php b/tests/unit/suites/libraries/joomla/cache/storage/JCacheStorageMock.php index 29ae01e031b1d..5389d26538d47 100644 --- a/tests/unit/suites/libraries/joomla/cache/storage/JCacheStorageMock.php +++ b/tests/unit/suites/libraries/joomla/cache/storage/JCacheStorageMock.php @@ -105,18 +105,6 @@ public function clean($group, $mode = null) return ($this->_storage = array()); } - /** - * Test to see if the storage handler is available. - * - * @return boolean True on success, false otherwise - * - * @since 12.1 - */ - public static function isSupported() - { - return true; - } - /** * Get a cache_id string from an id/group pair * From 70241c871aa4c4a5a42ff52066e94470b48f556d Mon Sep 17 00:00:00 2001 From: Frank Mayer Date: Thu, 29 Dec 2016 17:02:52 +0200 Subject: [PATCH 2/4] Some improvements in tests #4: - removal of some unused variables (and inserted todo's if unclear) - removal of null assignments on class properties; --- tests/unit/core/case/database.php | 1 - tests/unit/core/mock/database/driver.php | 2 +- .../suites/database/driver/mysql/JDatabaseExporterMysqlTest.php | 2 +- .../database/driver/mysqli/JDatabaseExporterMysqliTest.php | 2 +- .../database/driver/pdomysql/JDatabaseExporterPdomysqlTest.php | 2 +- .../driver/postgresql/JDatabaseExporterPostgresqlTest.php | 2 +- .../suites/libraries/joomla/cache/storage/JCacheStorageMock.php | 2 ++ .../unit/suites/libraries/joomla/feed/stubs/JFeedParserMock.php | 2 +- .../suites/libraries/joomla/google/JGoogleAuthOauth2Test.php | 2 +- tests/unit/suites/libraries/joomla/language/JLanguageTest.php | 2 ++ tests/unit/suites/libraries/joomla/oauth2/JOauth2ClientTest.php | 2 +- 11 files changed, 12 insertions(+), 9 deletions(-) diff --git a/tests/unit/core/case/database.php b/tests/unit/core/case/database.php index 160dc26edc065..efc4f527246a9 100644 --- a/tests/unit/core/case/database.php +++ b/tests/unit/core/case/database.php @@ -485,7 +485,6 @@ protected function saveFactoryState() protected function setErrorHandlers($errorHandlers) { $mode = null; - $options = null; foreach ($errorHandlers as $type => $params) { diff --git a/tests/unit/core/mock/database/driver.php b/tests/unit/core/mock/database/driver.php index 424c5e2dff7ca..cd3ceb00c41f0 100644 --- a/tests/unit/core/mock/database/driver.php +++ b/tests/unit/core/mock/database/driver.php @@ -20,7 +20,7 @@ class TestMockDatabaseDriver * @var mixed * @since 11.3 */ - public static $lastQuery = null; + public static $lastQuery; /** * Creates and instance of the mock JDatabaseDriver object. diff --git a/tests/unit/suites/database/driver/mysql/JDatabaseExporterMysqlTest.php b/tests/unit/suites/database/driver/mysql/JDatabaseExporterMysqlTest.php index feae207646655..302b432389fbf 100644 --- a/tests/unit/suites/database/driver/mysql/JDatabaseExporterMysqlTest.php +++ b/tests/unit/suites/database/driver/mysql/JDatabaseExporterMysqlTest.php @@ -29,7 +29,7 @@ class JDatabaseExporterMysqlTest extends TestCase /** * @var JDatabaseDriverMysql The mocked database object for use by test methods. */ - protected $dbo = null; + protected $dbo; /** * This method is called before the first test of this test class is run. diff --git a/tests/unit/suites/database/driver/mysqli/JDatabaseExporterMysqliTest.php b/tests/unit/suites/database/driver/mysqli/JDatabaseExporterMysqliTest.php index 3e5006eb35a3a..df92d2e90b13f 100644 --- a/tests/unit/suites/database/driver/mysqli/JDatabaseExporterMysqliTest.php +++ b/tests/unit/suites/database/driver/mysqli/JDatabaseExporterMysqliTest.php @@ -18,7 +18,7 @@ class JDatabaseExporterMysqliTest extends TestCase /** * @var JDatabaseDriverMysqli The mocked database object for use by test methods. */ - protected $dbo = null; + protected $dbo; /** * Sets up the testing conditions diff --git a/tests/unit/suites/database/driver/pdomysql/JDatabaseExporterPdomysqlTest.php b/tests/unit/suites/database/driver/pdomysql/JDatabaseExporterPdomysqlTest.php index 87d79d3de0562..47e444c96893a 100644 --- a/tests/unit/suites/database/driver/pdomysql/JDatabaseExporterPdomysqlTest.php +++ b/tests/unit/suites/database/driver/pdomysql/JDatabaseExporterPdomysqlTest.php @@ -20,7 +20,7 @@ class JDatabaseExporterPdomysqlTest extends PHPUnit_Framework_TestCase * @var object The mocked database object for use by test methods. * @since 3.4 */ - protected $dbo = null; + protected $dbo; /** * Sets up the testing conditions diff --git a/tests/unit/suites/database/driver/postgresql/JDatabaseExporterPostgresqlTest.php b/tests/unit/suites/database/driver/postgresql/JDatabaseExporterPostgresqlTest.php index 30b0db0f57e87..72351be9e99ea 100644 --- a/tests/unit/suites/database/driver/postgresql/JDatabaseExporterPostgresqlTest.php +++ b/tests/unit/suites/database/driver/postgresql/JDatabaseExporterPostgresqlTest.php @@ -18,7 +18,7 @@ class JDatabaseExporterPostgresqlTest extends TestCase /** * @var JDatabaseDriverPostgresql The mocked database object for use by test methods. */ - protected $dbo = null; + protected $dbo; /** * @var string A query string or object. diff --git a/tests/unit/suites/libraries/joomla/cache/storage/JCacheStorageMock.php b/tests/unit/suites/libraries/joomla/cache/storage/JCacheStorageMock.php index 5389d26538d47..92e1295e4ef1d 100644 --- a/tests/unit/suites/libraries/joomla/cache/storage/JCacheStorageMock.php +++ b/tests/unit/suites/libraries/joomla/cache/storage/JCacheStorageMock.php @@ -44,6 +44,8 @@ public function __construct($options = array()) */ public function get($id, $group, $checkTime = true) { + //todo: OK to remove this unused assignment? Or is some implementation missing? + $cache_id = $this->_getCacheId($id, $group); if (isset($this->_storage[$id])) diff --git a/tests/unit/suites/libraries/joomla/feed/stubs/JFeedParserMock.php b/tests/unit/suites/libraries/joomla/feed/stubs/JFeedParserMock.php index 0db8c016eaac4..b1e28398447eb 100644 --- a/tests/unit/suites/libraries/joomla/feed/stubs/JFeedParserMock.php +++ b/tests/unit/suites/libraries/joomla/feed/stubs/JFeedParserMock.php @@ -20,7 +20,7 @@ class JFeedParserMock extends JFeedParser * @var mixed The value to return when the parse method is called. * @since 12.3 */ - public static $parseReturn = null; + public static $parseReturn; /** * Do Nothing. diff --git a/tests/unit/suites/libraries/joomla/google/JGoogleAuthOauth2Test.php b/tests/unit/suites/libraries/joomla/google/JGoogleAuthOauth2Test.php index 29b27a4e983c8..563ddf0464cb7 100644 --- a/tests/unit/suites/libraries/joomla/google/JGoogleAuthOauth2Test.php +++ b/tests/unit/suites/libraries/joomla/google/JGoogleAuthOauth2Test.php @@ -51,7 +51,7 @@ class JGoogleAuthOauth2Test extends TestCase * * @var int */ - private static $closed = null; + private static $closed; /** * Backup of the SERVER superglobal diff --git a/tests/unit/suites/libraries/joomla/language/JLanguageTest.php b/tests/unit/suites/libraries/joomla/language/JLanguageTest.php index 1e420b9c3b57b..5f6b777edf91b 100644 --- a/tests/unit/suites/libraries/joomla/language/JLanguageTest.php +++ b/tests/unit/suites/libraries/joomla/language/JLanguageTest.php @@ -1201,6 +1201,8 @@ public function testParseXMLLanguageFile() 'Line: ' . __LINE__ ); + //todo: OK to remove this unused assignment and following assertion? Or is some implementation missing? + $path2 = __DIR__ . '/data/language/es-ES/es-ES.xml'; $this->assertEquals( $option, diff --git a/tests/unit/suites/libraries/joomla/oauth2/JOauth2ClientTest.php b/tests/unit/suites/libraries/joomla/oauth2/JOauth2ClientTest.php index ba74cd87f8975..e7febdb0d5a40 100644 --- a/tests/unit/suites/libraries/joomla/oauth2/JOauth2ClientTest.php +++ b/tests/unit/suites/libraries/joomla/oauth2/JOauth2ClientTest.php @@ -48,7 +48,7 @@ class JOAuth2ClientTest extends TestCase * * @var int */ - private static $closed = null; + private static $closed; /** * Backup of the SERVER superglobal From 6773d92202a3ed0d769166a7ca9bc43c66dee5ce Mon Sep 17 00:00:00 2001 From: Frank Mayer Date: Fri, 30 Dec 2016 15:27:44 +0200 Subject: [PATCH 3/4] Fix, according to @mbabker's comment --- .../joomla/cache/storage/JCacheStorageMock.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/unit/suites/libraries/joomla/cache/storage/JCacheStorageMock.php b/tests/unit/suites/libraries/joomla/cache/storage/JCacheStorageMock.php index 92e1295e4ef1d..8abfbf213c9d5 100644 --- a/tests/unit/suites/libraries/joomla/cache/storage/JCacheStorageMock.php +++ b/tests/unit/suites/libraries/joomla/cache/storage/JCacheStorageMock.php @@ -44,13 +44,11 @@ public function __construct($options = array()) */ public function get($id, $group, $checkTime = true) { - //todo: OK to remove this unused assignment? Or is some implementation missing? - $cache_id = $this->_getCacheId($id, $group); - if (isset($this->_storage[$id])) + if (isset($this->_storage[$cache_id])) { - return $this->_storage[$id]; + return $this->_storage[$cache_id]; } return false; @@ -71,7 +69,7 @@ public function store($id, $group, $data) { $cache_id = $this->_getCacheId($id, $group); - return ($this->_storage[$id] = $data); + return ($this->_storage[$cache_id] = $data); } /** @@ -87,7 +85,7 @@ public function store($id, $group, $data) public function remove($id, $group) { $cache_id = $this->_getCacheId($id, $group); - unset($this->_storage[$id]); + unset($this->_storage[$cache_id]); } /** From cae13bf7923b451c61d7a5e5c908763f8093be6e Mon Sep 17 00:00:00 2001 From: Frank Mayer Date: Fri, 30 Dec 2016 15:29:51 +0200 Subject: [PATCH 4/4] Another fix, according to @mbabker's comment --- .../suites/libraries/joomla/language/JLanguageTest.php | 9 --------- 1 file changed, 9 deletions(-) diff --git a/tests/unit/suites/libraries/joomla/language/JLanguageTest.php b/tests/unit/suites/libraries/joomla/language/JLanguageTest.php index 5f6b777edf91b..ea1ff9fc11abc 100644 --- a/tests/unit/suites/libraries/joomla/language/JLanguageTest.php +++ b/tests/unit/suites/libraries/joomla/language/JLanguageTest.php @@ -1200,15 +1200,6 @@ public function testParseXMLLanguageFile() JLanguage::parseXMLLanguageFile($path), 'Line: ' . __LINE__ ); - - //todo: OK to remove this unused assignment and following assertion? Or is some implementation missing? - - $path2 = __DIR__ . '/data/language/es-ES/es-ES.xml'; - $this->assertEquals( - $option, - JLanguage::parseXMLLanguageFile($path), - 'Line: ' . __LINE__ - ); } /**