From ff11ae9198d12fda6a9209be386bf80c8ce6d60b Mon Sep 17 00:00:00 2001 From: George Wilson Date: Wed, 26 Jul 2017 14:35:09 +0100 Subject: [PATCH] Unit Test CS (#13433) * Whats going on now * Some exclusions * Remove function comment * Add some more excludes * Remove for now * Add another exception * Lots of small tweaks to codestyle in tests * Fix some the plugins CS * More plugin cs fixing * Uppercase * Couple of extra fixes * empty lines around control structure * PHPCS autofixers * Apply PHPCS2.x autofixers to JRouter tests * Apply PHPCS2.x autofixers to JComponentRouter * Fix null lowercase * Code style in application tests * Fix JApplicationWeb tests * Remove non-PHP files from tests * Clean up email cloak unit test * Remove commented code * Fix tests failing after merging in develop --- build/phpcs/Joomla/ruleset.xml | 28 +++- tests/codeception/_bootstrap.php | 1 + tests/codeception/functional/_bootstrap.php | 1 + tests/unit/core/mock/dispatcher.php | 1 + tests/unit/stubs/discover2/endeavour.php | 2 +- .../includes/JAdministratorHelperTest.php | 1 - .../JDatabaseIteratorPostgresqlTest.php | 2 +- .../JDatabaseQueryPostgresqlTest.php | 2 +- .../sqlite/JDatabaseQuerySqliteTest.php | 2 +- .../sqlsrv/JDatabaseQuerySqlsrvTest.php | 2 +- .../cms/application/JApplicationCmsTest.php | 18 +-- .../router/JComponentRouterBaseTest.php | 7 +- .../router/JComponentRouterViewTest.php | 5 +- .../JComponentRouterViewconfigurationTest.php | 3 + .../rules/JComponentRouterRulesMenuTest.php | 19 +-- .../rules/JComponentRouterRulesNomenuTest.php | 6 +- .../JComponentRouterRulesStandardTest.php | 4 +- .../JComponentRouterRulesMenuInspector.php | 8 +- .../JComponentRouterRulesNomenuInspector.php | 6 +- ...ockJComponentRouterRulesMenuMenuObject.php | 128 +++++++++--------- .../router/stubs/ComContentRouter.php | 1 + .../stubs/JComponentRouterBaseInspector.php | 8 +- .../stubs/JComponentRouterViewInspector.php | 54 ++++---- .../router/stubs/componentrouter.php | 2 + .../router/stubs/componentrouterrule.php | 74 +++++----- .../libraries/cms/html/JHtmlMenuTest.php | 2 +- .../cms/installer/JInstallerAdapterTest.php | 8 +- .../libraries/cms/router/JRouterSiteTest.php | 1 + .../libraries/cms/router/JRouterTest.php | 10 +- .../application/JApplicationBaseTest.php | 2 +- .../application/JApplicationWebTest.php | 16 +-- .../libraries/joomla/archive/JArchiveTest.php | 5 +- .../joomla/archive/JArchiveTestCase.php | 2 +- .../joomla/database/JDatabaseQueryTest.php | 2 +- .../form/field/JFormFieldModuleLayoutTest.php | 2 +- .../form/fields/JFormFieldFileListTest.php | 1 + .../joomla/github/JGithubPackageUsersTest.php | 2 +- ...GithubPackageRepositoriesDownloadsTest.php | 2 +- .../joomla/google/JGoogleAuthOauth2Test.php | 1 - .../libraries/joomla/image/JImageTest.php | 8 +- .../libraries/joomla/input/JInputCliTest.php | 12 +- .../joomla/session/handler/array.php | 17 ++- .../libraries/joomla/user/JUserHelperTest.php | 4 +- .../libraries/joomla/view/JViewHtmlTest.php | 3 +- .../emailcloak/PlgContentEmailcloakTest.php | 67 +++++---- 45 files changed, 299 insertions(+), 253 deletions(-) diff --git a/build/phpcs/Joomla/ruleset.xml b/build/phpcs/Joomla/ruleset.xml index b644453af4001..0b2d1219aea8c 100644 --- a/build/phpcs/Joomla/ruleset.xml +++ b/build/phpcs/Joomla/ruleset.xml @@ -5,7 +5,6 @@ build/* docs/* - tests/* cache/* tmp/* logs/* @@ -25,6 +24,15 @@ configuration.php installation/template/index.php plugins/captcha/recaptcha/recaptchalib.php + + tests/unit/suites/libraries/joomla/model/stubs/barbaz.php + tests/unit/suites/libraries/joomla/view/layouts1/fringe/division.php + tests/unit/suites/libraries/joomla/view/layouts1/olivia.php + tests/unit/suites/libraries/joomla/view/layouts1/peter.php + tests/unit/suites/libraries/joomla/view/layouts2/fauxlivia.php + tests/unit/suites/libraries/joomla/view/layouts2/olivia.php + tests/unit/suites/libraries/legacy/controller/stubs/component1/controller.json.php + tests/unit/suites/libraries/legacy/controller/stubs/component2/controller.php RoboFile.php @@ -54,6 +62,7 @@ */tmpl/* templates/* layouts/* + tests/* @@ -136,12 +145,23 @@ - + + tests/* + + + + tests/* + + + + tests/* + templates/* layouts/* + tests/* @@ -151,7 +171,9 @@ layouts/* - + + tests/* + diff --git a/tests/codeception/_bootstrap.php b/tests/codeception/_bootstrap.php index 243f9c85bc6da..074505f2795c7 100644 --- a/tests/codeception/_bootstrap.php +++ b/tests/codeception/_bootstrap.php @@ -1,2 +1,3 @@ setMockClassName('') ->disableOriginalConstructor() ->getMock(); + // Mock selected methods. $test->assignMockReturns( $mockObject, array( diff --git a/tests/unit/stubs/discover2/endeavour.php b/tests/unit/stubs/discover2/endeavour.php index a0bf71975ec4c..cbdb45e524674 100644 --- a/tests/unit/stubs/discover2/endeavour.php +++ b/tests/unit/stubs/discover2/endeavour.php @@ -8,4 +8,4 @@ class ShuttleEndeavour { -} \ No newline at end of file +} diff --git a/tests/unit/suites/administrator/includes/JAdministratorHelperTest.php b/tests/unit/suites/administrator/includes/JAdministratorHelperTest.php index 939ba1b650e84..070908b074cee 100644 --- a/tests/unit/suites/administrator/includes/JAdministratorHelperTest.php +++ b/tests/unit/suites/administrator/includes/JAdministratorHelperTest.php @@ -29,7 +29,6 @@ class JAdministratorHelperTest extends TestCase */ protected function setUp() { - //$this->object = new JErrorPage; $this->saveFactoryState(); JFactory::$application = $this->getMockCmsApp(); diff --git a/tests/unit/suites/database/driver/postgresql/JDatabaseIteratorPostgresqlTest.php b/tests/unit/suites/database/driver/postgresql/JDatabaseIteratorPostgresqlTest.php index 4ad7107b61ef8..ea51fe71f9a50 100644 --- a/tests/unit/suites/database/driver/postgresql/JDatabaseIteratorPostgresqlTest.php +++ b/tests/unit/suites/database/driver/postgresql/JDatabaseIteratorPostgresqlTest.php @@ -133,7 +133,7 @@ public function testForEach($select, $from, $column, $class, $limit, $offset, $e $iterator = self::$driver->getIterator($column, $class); // Run the Iterator pattern - $this->assertEquals($expected,iterator_to_array($iterator)); + $this->assertEquals($expected, iterator_to_array($iterator)); } /** diff --git a/tests/unit/suites/database/driver/postgresql/JDatabaseQueryPostgresqlTest.php b/tests/unit/suites/database/driver/postgresql/JDatabaseQueryPostgresqlTest.php index aeef9eaccf4c1..00f80bc5e9675 100644 --- a/tests/unit/suites/database/driver/postgresql/JDatabaseQueryPostgresqlTest.php +++ b/tests/unit/suites/database/driver/postgresql/JDatabaseQueryPostgresqlTest.php @@ -1180,7 +1180,7 @@ public function testReturning() public function seedDateAdd() { return array( - // date, interval, datepart, expected + // Elements: date, interval, datepart, expected 'Add date' => array('2008-12-31', '1', 'day', "timestamp '2008-12-31' + interval '1 day'"), 'Subtract date' => array('2008-12-31', '-1', 'day', "timestamp '2008-12-31' - interval '1 day'"), 'Add datetime' => array('2008-12-31 23:59:59', '1', 'day', "timestamp '2008-12-31 23:59:59' + interval '1 day'"), diff --git a/tests/unit/suites/database/driver/sqlite/JDatabaseQuerySqliteTest.php b/tests/unit/suites/database/driver/sqlite/JDatabaseQuerySqliteTest.php index 2308d9f877083..3624743ebd9be 100644 --- a/tests/unit/suites/database/driver/sqlite/JDatabaseQuerySqliteTest.php +++ b/tests/unit/suites/database/driver/sqlite/JDatabaseQuerySqliteTest.php @@ -73,7 +73,7 @@ protected function tearDown() public function seedDateAdd() { return array( - // date, interval, datepart, expected + // Elements: date, interval, datepart, expected 'Add date' => array('2008-12-31', '1', 'DAY', "datetime('2008-12-31', '+1 DAY')"), 'Subtract date' => array('2008-12-31', '-1', 'DAY', "datetime('2008-12-31', '-1 DAY')"), 'Add datetime' => array('2008-12-31 23:59:59', '1', 'DAY', "datetime('2008-12-31 23:59:59', '+1 DAY')"), diff --git a/tests/unit/suites/database/driver/sqlsrv/JDatabaseQuerySqlsrvTest.php b/tests/unit/suites/database/driver/sqlsrv/JDatabaseQuerySqlsrvTest.php index 272727e47a745..73df67da7a7f6 100644 --- a/tests/unit/suites/database/driver/sqlsrv/JDatabaseQuerySqlsrvTest.php +++ b/tests/unit/suites/database/driver/sqlsrv/JDatabaseQuerySqlsrvTest.php @@ -73,7 +73,7 @@ protected function tearDown() public function seedDateAdd() { return array( - // date, interval, datepart, expected + // Elements: date, interval, datepart, expected 'Add date' => array('2008-12-31', '1', 'day', "DATEADD('day', '1', '2008-12-31')"), 'Subtract date' => array('2008-12-31', '-1', 'day', "DATEADD('day', '-1', '2008-12-31')"), 'Add datetime' => array('2008-12-31 23:59:59', '1', 'day', "DATEADD('day', '1', '2008-12-31 23:59:59')"), diff --git a/tests/unit/suites/libraries/cms/application/JApplicationCmsTest.php b/tests/unit/suites/libraries/cms/application/JApplicationCmsTest.php index bf8047c45988d..58cc151aa79eb 100644 --- a/tests/unit/suites/libraries/cms/application/JApplicationCmsTest.php +++ b/tests/unit/suites/libraries/cms/application/JApplicationCmsTest.php @@ -459,9 +459,9 @@ public function testRedirect() $this->class->headers[2] ); - $this->assertRegexp('/Expires/',$this->class->headers[3][0]); + $this->assertRegexp('/Expires/', $this->class->headers[3][0]); - $this->assertRegexp('/Last-Modified/',$this->class->headers[4][0]); + $this->assertRegexp('/Last-Modified/', $this->class->headers[4][0]); $this->assertEquals( array('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0', true, null), @@ -529,9 +529,9 @@ public function testRedirectLegacy() $this->class->headers[2] ); - $this->assertRegexp('/Expires/',$this->class->headers[3][0]); + $this->assertRegexp('/Expires/', $this->class->headers[3][0]); - $this->assertRegexp('/Last-Modified/',$this->class->headers[4][0]); + $this->assertRegexp('/Last-Modified/', $this->class->headers[4][0]); $this->assertEquals( array('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0', true, null), @@ -595,9 +595,9 @@ public function testRedirectLegacyWithEmptyMessageAndEmptyStatus() $this->class->headers[2] ); - $this->assertRegexp('/Expires/',$this->class->headers[3][0]); + $this->assertRegexp('/Expires/', $this->class->headers[3][0]); - $this->assertRegexp('/Last-Modified/',$this->class->headers[4][0]); + $this->assertRegexp('/Last-Modified/', $this->class->headers[4][0]); $this->assertEquals( array('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0', true, null), @@ -704,7 +704,7 @@ public function testRedirectWithMoved() ); $this->assertEquals( - array('Location: ' . $url, true, null), + array('Location: ' . $url, true, null), $this->class->headers[1] ); @@ -713,9 +713,9 @@ public function testRedirectWithMoved() $this->class->headers[2] ); - $this->assertRegexp('/Expires/',$this->class->headers[3][0]); + $this->assertRegexp('/Expires/', $this->class->headers[3][0]); - $this->assertRegexp('/Last-Modified/',$this->class->headers[4][0]); + $this->assertRegexp('/Last-Modified/', $this->class->headers[4][0]); $this->assertEquals( array('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0', true, null), diff --git a/tests/unit/suites/libraries/cms/component/router/JComponentRouterBaseTest.php b/tests/unit/suites/libraries/cms/component/router/JComponentRouterBaseTest.php index 14a1d88108a4d..13f74656503a5 100644 --- a/tests/unit/suites/libraries/cms/component/router/JComponentRouterBaseTest.php +++ b/tests/unit/suites/libraries/cms/component/router/JComponentRouterBaseTest.php @@ -37,7 +37,7 @@ public function testConstruct() * Test if standard setup of JComponentRouterBase works and $app and * $menu are properly populated */ - $object = new JComponentRouterBaseInspector(); + $object = new JComponentRouterBaseInspector; $this->assertInstanceOf('JComponentRouterInterface', $object); $this->assertInstanceOf('JComponentRouterBase', $object); $this->assertEquals($app, $object->app); @@ -51,13 +51,14 @@ public function testConstruct() $app2 = TestMockApplication::create($this); $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 + + // The original $app is not the same object as $app2, thus we did not use JFactory $this->assertNotSame($app, $object->app); /** * Test if the setup works when both an app and menu object is handed over */ - $menu2 = new stdClass(); + $menu2 = new stdClass; $object = new JComponentRouterBaseInspector($app, $menu2); $this->assertEquals($app, $object->app); $this->assertEquals($menu2, $object->menu); diff --git a/tests/unit/suites/libraries/cms/component/router/JComponentRouterViewTest.php b/tests/unit/suites/libraries/cms/component/router/JComponentRouterViewTest.php index 755579034bfd7..2c0c2f21dac2b 100644 --- a/tests/unit/suites/libraries/cms/component/router/JComponentRouterViewTest.php +++ b/tests/unit/suites/libraries/cms/component/router/JComponentRouterViewTest.php @@ -128,6 +128,7 @@ public function testGetViews() public function casesGetPath() { $cases = array(); + // No view, so we don't have a path to return. $cases[] = array(array('task' => 'edit'), array()); @@ -140,7 +141,7 @@ public function casesGetPath() // View with parent and children $cases[] = array(array('view' => 'category', 'id' => '9'), array('category' => array(9 => '9:uncategorised'), 'categories' => array(9 => '9:uncategorised'))); - //View with parent, no children + // View with parent, no children $cases[] = array(array('view' => 'article', 'id' => '42:question-for-everything', 'catid' => '9'), array( 'article' => array(42 => '42:question-for-everything'), @@ -149,7 +150,7 @@ public function casesGetPath() ) ); - //View with parent, no children and nested view + // View with parent, no children and nested view $cases[] = array(array('view' => 'article', 'id' => '42:question-for-everything', 'catid' => '20'), array( 'article' => array(42 => '42:question-for-everything'), diff --git a/tests/unit/suites/libraries/cms/component/router/JComponentRouterViewconfigurationTest.php b/tests/unit/suites/libraries/cms/component/router/JComponentRouterViewconfigurationTest.php index b769a5d2c1e34..7479b989aea7d 100644 --- a/tests/unit/suites/libraries/cms/component/router/JComponentRouterViewconfigurationTest.php +++ b/tests/unit/suites/libraries/cms/component/router/JComponentRouterViewconfigurationTest.php @@ -144,6 +144,7 @@ public function testSetParent() $this->assertEquals(array($this->object), $parent2->children); $this->assertEquals(array('category', 'test'), $this->object->path); $this->assertEquals(array('catid'), $parent2->child_keys); + // Make sure that the original parent is cleaned up $this->assertEquals(array(), $parent->children); $this->assertEquals(array(), $parent->child_keys); @@ -154,6 +155,7 @@ public function testSetParent() $this->assertEquals($parent3, $this->object->parent); $this->assertEquals('formid', $this->object->parent_key); $this->assertEquals(array('formid'), $parent3->child_keys); + // Make sure that the original parent is cleaned up $this->assertEquals(array(), $parent2->children); $this->assertEquals(array(), $parent2->child_keys); @@ -191,6 +193,7 @@ public function testAddLayout() $this->assertEquals(array('default'), $this->object->layouts); $this->assertEquals($this->object, $this->object->addLayout('form')); $this->assertEquals(array('default', 'form'), $this->object->layouts); + // Make sure that a layout can only be added once $this->object->addLayout('form'); $this->assertEquals(array('default', 'form'), $this->object->layouts); diff --git a/tests/unit/suites/libraries/cms/component/router/rules/JComponentRouterRulesMenuTest.php b/tests/unit/suites/libraries/cms/component/router/rules/JComponentRouterRulesMenuTest.php index ce03db8a20b0a..ceeaf7a67701a 100644 --- a/tests/unit/suites/libraries/cms/component/router/rules/JComponentRouterRulesMenuTest.php +++ b/tests/unit/suites/libraries/cms/component/router/rules/JComponentRouterRulesMenuTest.php @@ -18,8 +18,8 @@ * @subpackage Component * @since 3.5 */ -class JComponentRouterRulesMenuTest extends TestCaseDatabase { - +class JComponentRouterRulesMenuTest extends TestCaseDatabase +{ /** * Object under test * @@ -63,7 +63,7 @@ protected function setUp() $router->registerView($featured); $form = new JComponentRouterViewconfiguration('form'); $router->registerView($form); - $router->menu = new MockJComponentRouterRulesMenuMenuObject(); + $router->menu = new MockJComponentRouterRulesMenuMenuObject; $this->object = new JComponentRouterRulesMenuInspector($router); } @@ -116,7 +116,8 @@ public function testConstruct() 'featured' => '47', 'categories' => array(14 => '48'), 'category' => array (20 => '49')) - ), $this->object->get('lookup')); + ), $this->object->get('lookup') + ); } /** @@ -129,7 +130,7 @@ public function testConstruct() public function casesPreprocess() { $cases = array(); - + // Check direct link to a simple view $cases[] = array(array('option' => 'com_content', 'view' => 'featured'), array('option' => 'com_content', 'view' => 'featured', 'Itemid' => '47')); @@ -244,8 +245,9 @@ public function testBuildLookup() 'featured' => '47', 'categories' => array(14 => '48'), 'category' => array (20 => '49')) - ), $this->object->get('lookup')); - + ), $this->object->get('lookup') + ); + $this->object->runBuildLookUp('en-GB'); $this->assertEquals(array( '*' => array( @@ -256,6 +258,7 @@ public function testBuildLookup() 'featured' => '51', 'categories' => array(14 => '50'), 'category' => array (20 => '49')) - ), $this->object->get('lookup')); + ), $this->object->get('lookup') + ); } } diff --git a/tests/unit/suites/libraries/cms/component/router/rules/JComponentRouterRulesNomenuTest.php b/tests/unit/suites/libraries/cms/component/router/rules/JComponentRouterRulesNomenuTest.php index 8460fdd9d4299..2cd4c4873293f 100644 --- a/tests/unit/suites/libraries/cms/component/router/rules/JComponentRouterRulesNomenuTest.php +++ b/tests/unit/suites/libraries/cms/component/router/rules/JComponentRouterRulesNomenuTest.php @@ -17,8 +17,8 @@ * @subpackage Component * @since 3.4 */ -class JComponentRouterRulesNomenuTest extends TestCase { - +class JComponentRouterRulesNomenuTest extends TestCase +{ /** * Object under test * @@ -115,7 +115,7 @@ public function testParse() $router = $this->object->get('router'); $router->menu->expects($this->any()) ->method('getActive') - ->will($this->returnValue(new stdClass())); + ->will($this->returnValue(new stdClass)); $segments = array('article', '42:the-answer'); $vars = array('option' => 'com_content'); $this->object->parse($segments, $vars); diff --git a/tests/unit/suites/libraries/cms/component/router/rules/JComponentRouterRulesStandardTest.php b/tests/unit/suites/libraries/cms/component/router/rules/JComponentRouterRulesStandardTest.php index d6e57717acf16..11a2c6541a1b0 100644 --- a/tests/unit/suites/libraries/cms/component/router/rules/JComponentRouterRulesStandardTest.php +++ b/tests/unit/suites/libraries/cms/component/router/rules/JComponentRouterRulesStandardTest.php @@ -17,8 +17,8 @@ * @subpackage Component * @since 3.7.0 */ -class JComponentRouterRulesStandardTest extends TestCaseDatabase { - +class JComponentRouterRulesStandardTest extends TestCaseDatabase +{ /** * Object under test * diff --git a/tests/unit/suites/libraries/cms/component/router/rules/stubs/JComponentRouterRulesMenuInspector.php b/tests/unit/suites/libraries/cms/component/router/rules/stubs/JComponentRouterRulesMenuInspector.php index 2bb2fa339c857..43207aebbce75 100644 --- a/tests/unit/suites/libraries/cms/component/router/rules/stubs/JComponentRouterRulesMenuInspector.php +++ b/tests/unit/suites/libraries/cms/component/router/rules/stubs/JComponentRouterRulesMenuInspector.php @@ -18,7 +18,7 @@ class JComponentRouterRulesMenuInspector extends JComponentRouterRulesMenu { /** * Gets an attribute of the object - * + * * @param string $key Attributename to return * * @return mixed Attributes of the object @@ -32,7 +32,7 @@ public function get($key) /** * Sets an attribute of the object - * + * * @param string $key Attributename to return * @param mixed $value Value to be set * @@ -44,9 +44,9 @@ public function set($key, $value) { $this->$key = $value; } - + public function runBuildLookup($language = '*') { return $this->buildLookup($language); } -} \ No newline at end of file +} diff --git a/tests/unit/suites/libraries/cms/component/router/rules/stubs/JComponentRouterRulesNomenuInspector.php b/tests/unit/suites/libraries/cms/component/router/rules/stubs/JComponentRouterRulesNomenuInspector.php index 626050d9b1fc3..7e9208a6f34c2 100644 --- a/tests/unit/suites/libraries/cms/component/router/rules/stubs/JComponentRouterRulesNomenuInspector.php +++ b/tests/unit/suites/libraries/cms/component/router/rules/stubs/JComponentRouterRulesNomenuInspector.php @@ -18,7 +18,7 @@ class JComponentRouterRulesNomenuInspector extends JComponentRouterRulesNomenu { /** * Gets an attribute of the object - * + * * @param string $key Attributename to return * * @return mixed Attributes of the object @@ -32,7 +32,7 @@ public function get($key) /** * Sets an attribute of the object - * + * * @param string $key Attributename to return * @param mixed $value Value to be set * @@ -44,4 +44,4 @@ public function set($key, $value) { $this->$key = $value; } -} \ No newline at end of file +} diff --git a/tests/unit/suites/libraries/cms/component/router/rules/stubs/MockJComponentRouterRulesMenuMenuObject.php b/tests/unit/suites/libraries/cms/component/router/rules/stubs/MockJComponentRouterRulesMenuMenuObject.php index 238f2a872ceaf..617cd42c9ff92 100644 --- a/tests/unit/suites/libraries/cms/component/router/rules/stubs/MockJComponentRouterRulesMenuMenuObject.php +++ b/tests/unit/suites/libraries/cms/component/router/rules/stubs/MockJComponentRouterRulesMenuMenuObject.php @@ -18,104 +18,104 @@ class MockJComponentRouterRulesMenuMenuObject { /** * Menuitems - * + * * @var array */ protected $items = array(); /** * Active menuitem - * + * * @var integer */ public $active = 49; /** * Constructor for this object - * + * * @since 3.4 */ public function __construct() { $this->items[47] = (object) array( - 'id' => '47', - 'menutype' => 'testmenu', - 'title' => 'Content Home', - 'alias' => 'content-home', - 'route' => 'content-home', - 'link' => 'index.php?option=com_content&view=featured', - 'type' => 'component', - 'level' => '1', - 'language' => '*', + 'id' => '47', + 'menutype' => 'testmenu', + 'title' => 'Content Home', + 'alias' => 'content-home', + 'route' => 'content-home', + 'link' => 'index.php?option=com_content&view=featured', + 'type' => 'component', + 'level' => '1', + 'language' => '*', 'component_id' => '22', 'component' => 'com_content', - 'parent_id' => '0', + 'parent_id' => '0', 'query' => array('option' => 'com_content', 'view' => 'featured')); $this->items[48] = (object) array( - 'id' => '48', - 'menutype' => 'testmenu', - 'title' => 'Categories View', - 'alias' => 'categories', - 'route' => 'content-home/categories', - 'link' => 'index.php?option=com_content&view=categories&id=14', - 'type' => 'component', - 'level' => '2', - 'language' => '*', - 'component_id' => '22', + 'id' => '48', + 'menutype' => 'testmenu', + 'title' => 'Categories View', + 'alias' => 'categories', + 'route' => 'content-home/categories', + 'link' => 'index.php?option=com_content&view=categories&id=14', + 'type' => 'component', + 'level' => '2', + 'language' => '*', + 'component_id' => '22', 'component' => 'com_content', - 'parent_id' => '47', + 'parent_id' => '47', 'query' => array('option' => 'com_content', 'view' => 'categories', 'id' => '14')); $this->items[49] = (object) array( - 'id' => '49', - 'menutype' => 'testmenu', - 'title' => 'Category View', - 'alias' => 'category-view', - 'route' => 'category-view', - 'link' => 'index.php?option=com_content&view=category&id=20', - 'type' => 'component', - 'level' => '1', - 'language' => '*', - 'component_id' => '22', + 'id' => '49', + 'menutype' => 'testmenu', + 'title' => 'Category View', + 'alias' => 'category-view', + 'route' => 'category-view', + 'link' => 'index.php?option=com_content&view=category&id=20', + 'type' => 'component', + 'level' => '1', + 'language' => '*', + 'component_id' => '22', 'component' => 'com_content', - 'parent_id' => '47', + 'parent_id' => '47', 'query' => array('option' => 'com_content', 'view' => 'category', 'id' => '20')); $this->items[50] = (object) array( - 'id' => '50', - 'menutype' => 'testmenu', - 'title' => 'Categories View', - 'alias' => 'categories', - 'route' => 'content-home/categories', - 'link' => 'index.php?option=com_content&view=categories&id=14', - 'type' => 'component', - 'level' => '2', - 'language' => 'en-GB', - 'component_id' => '22', + 'id' => '50', + 'menutype' => 'testmenu', + 'title' => 'Categories View', + 'alias' => 'categories', + 'route' => 'content-home/categories', + 'link' => 'index.php?option=com_content&view=categories&id=14', + 'type' => 'component', + 'level' => '2', + 'language' => 'en-GB', + 'component_id' => '22', 'component' => 'com_content', - 'parent_id' => '47', + 'parent_id' => '47', 'query' => array('option' => 'com_content', 'view' => 'categories', 'id' => '14')); - + $this->items[51] = (object) array( - 'id' => '51', - 'menutype' => 'testmenu', - 'title' => 'Content Home', - 'alias' => 'content-home', - 'route' => 'content-home', - 'link' => 'index.php?option=com_content&view=featured', - 'type' => 'component', - 'level' => '1', - 'language' => 'en-GB', - 'component_id' => '22', + 'id' => '51', + 'menutype' => 'testmenu', + 'title' => 'Content Home', + 'alias' => 'content-home', + 'route' => 'content-home', + 'link' => 'index.php?option=com_content&view=featured', + 'type' => 'component', + 'level' => '1', + 'language' => 'en-GB', + 'component_id' => '22', 'component' => 'com_content', - 'parent_id' => '0', + 'parent_id' => '0', 'query' => array('option' => 'com_content', 'view' => 'featured')); } /** * Gets the menu item set that fits the search array - * + * * @param array $attributes Search criteria * @param array $values Search criteria * @@ -164,7 +164,7 @@ public function getItems($attributes, $values) /** * Return the currently active menuitem - * + * * @return object Menuitem * @since 3.4 */ @@ -175,9 +175,9 @@ public function getActive() /** * Return the default menuitem for the language - * + * * @param string $language Language for the default - * + * * @return object Menuitem * @since 3.4 */ @@ -187,10 +187,10 @@ public function getDefault($language = '*') { return $this->items[47]; } - + if ($language == 'en-GB') { return $this->items[51]; } } -} \ No newline at end of file +} diff --git a/tests/unit/suites/libraries/cms/component/router/stubs/ComContentRouter.php b/tests/unit/suites/libraries/cms/component/router/stubs/ComContentRouter.php index e69593cace7eb..d0d61e799ddc6 100644 --- a/tests/unit/suites/libraries/cms/component/router/stubs/ComContentRouter.php +++ b/tests/unit/suites/libraries/cms/component/router/stubs/ComContentRouter.php @@ -19,6 +19,7 @@ class ContentRouterStandardRuleOnly extends JComponentRouterView { protected $noIDs = false; + protected $name = 'content'; /** diff --git a/tests/unit/suites/libraries/cms/component/router/stubs/JComponentRouterBaseInspector.php b/tests/unit/suites/libraries/cms/component/router/stubs/JComponentRouterBaseInspector.php index 41466d39282ee..f512e8c5e0cc7 100644 --- a/tests/unit/suites/libraries/cms/component/router/stubs/JComponentRouterBaseInspector.php +++ b/tests/unit/suites/libraries/cms/component/router/stubs/JComponentRouterBaseInspector.php @@ -18,7 +18,7 @@ class JComponentRouterBaseInspector extends JComponentRouterBase { /** * Runs the protected createURI() method - * + * * @param array $url valid inputs to the createURI() method * * @return object JUri object from the given parameters @@ -29,13 +29,13 @@ public function get($key) { return $this->$key; } - + public function build(&$query) { } - + public function parse(&$segments) { - + } } diff --git a/tests/unit/suites/libraries/cms/component/router/stubs/JComponentRouterViewInspector.php b/tests/unit/suites/libraries/cms/component/router/stubs/JComponentRouterViewInspector.php index 2533761e20166..cb42e87c288e9 100644 --- a/tests/unit/suites/libraries/cms/component/router/stubs/JComponentRouterViewInspector.php +++ b/tests/unit/suites/libraries/cms/component/router/stubs/JComponentRouterViewInspector.php @@ -18,7 +18,7 @@ class JComponentRouterViewInspector extends JComponentRouterView { /** * Gets an attribute of the object - * + * * @param string $key Attributename to return * * @return mixed Attributes of the object @@ -32,7 +32,7 @@ public function get($key) /** * Sets an attribute of the object - * + * * @param string $key Attributename to return * @param mixed $value Value to be set * @@ -46,14 +46,14 @@ public function set($key, $value) } /** - * Get content items of the type category - * - * @param int $id ID of the category to load - * - * @return array Categories path identified by $id - * - * @since 3.4 - */ + * Get content items of the type category + * + * @param int $id ID of the category to load + * + * @return array Categories path identified by $id + * + * @since 3.4 + */ public function getCategorySegment($id, $query) { $category = JCategories::getInstance($this->getName())->get($id); @@ -67,28 +67,28 @@ public function getCategorySegment($id, $query) } /** - * Get content items of the type categories - * - * @param int $id ID of the category to load - * - * @return array Categories path identified by $id - * - * @since 3.4 - */ + * Get content items of the type categories + * + * @param int $id ID of the category to load + * + * @return array Categories path identified by $id + * + * @since 3.4 + */ public function getCategoriesSegment($id, $query) { return $this->getCategorySegment($id, $query); } /** - * Get content items of the type article - * - * @param int $id ID of the article to load - * - * @return array article identified by $id - * - * @since 3.4 - */ + * Get content items of the type article + * + * @param int $id ID of the article to load + * + * @return array article identified by $id + * + * @since 3.4 + */ public function getArticleSegment($id, $query) { return array((int) $id => $id); @@ -100,4 +100,4 @@ public function getArticleSegment($id, $query) */ class FakeComponentURLCreator extends JComponentRouterViewInspector { -} \ No newline at end of file +} diff --git a/tests/unit/suites/libraries/cms/component/router/stubs/componentrouter.php b/tests/unit/suites/libraries/cms/component/router/stubs/componentrouter.php index 32d96a7173e28..9cba097de8aff 100644 --- a/tests/unit/suites/libraries/cms/component/router/stubs/componentrouter.php +++ b/tests/unit/suites/libraries/cms/component/router/stubs/componentrouter.php @@ -17,6 +17,7 @@ function ComtestBuildRoute(&$query) { $return = array(); + foreach ($query as $key => $var) { $return[] = $key . '-' . $var; @@ -35,6 +36,7 @@ function ComtestBuildRoute(&$query) function ComtestParseRoute(&$segments) { $return = array(); + foreach ($segments as $segment) { list($key, $var) = explode(':', $segment, 2); diff --git a/tests/unit/suites/libraries/cms/component/router/stubs/componentrouterrule.php b/tests/unit/suites/libraries/cms/component/router/stubs/componentrouterrule.php index 0fffe21f94f46..d9b92a2b72227 100644 --- a/tests/unit/suites/libraries/cms/component/router/stubs/componentrouterrule.php +++ b/tests/unit/suites/libraries/cms/component/router/stubs/componentrouterrule.php @@ -17,49 +17,49 @@ class TestComponentRouterRule implements JComponentRouterRulesInterface { /** - * Router this rule belongs to - * - * @var JComponentRouterView - * @since 3.4 - */ + * Router this rule belongs to + * + * @var JComponentRouterView + * @since 3.4 + */ protected $router; /** - * Class constructor. - * - * @param JComponentRouterView $router Router this rule belongs to - * - * @since 3.4 - */ + * Class constructor. + * + * @param JComponentRouterView $router Router this rule belongs to + * + * @since 3.4 + */ public function __construct(JComponentRouterView $router) { $this->router = $router; } /** - * Finds the right Itemid for this query - * - * @param array &$query The query array to process - * - * @return void - * - * @since 3.4 - */ + * Finds the right Itemid for this query + * + * @param array &$query The query array to process + * + * @return void + * + * @since 3.4 + */ public function preprocess(&$query) { $query['testrule'] = 'yes'; } /** - * Parse method - * - * @param array &$segments The URL segments to parse - * @param array &$vars The vars that result from the segments - * - * @return void - * - * @since 3.4 - */ + * Parse method + * + * @param array &$segments The URL segments to parse + * @param array &$vars The vars that result from the segments + * + * @return void + * + * @since 3.4 + */ public function parse(&$segments, &$vars) { array_pop($segments); @@ -67,15 +67,15 @@ public function parse(&$segments, &$vars) } /** - * Build method - * - * @param array &$query The vars that should be converted - * @param array &$segments The URL segments to create - * - * @return void - * - * @since 3.4 - */ + * Build method + * + * @param array &$query The vars that should be converted + * @param array &$segments The URL segments to create + * + * @return void + * + * @since 3.4 + */ public function build(&$query, &$segments) { array_pop($query); diff --git a/tests/unit/suites/libraries/cms/html/JHtmlMenuTest.php b/tests/unit/suites/libraries/cms/html/JHtmlMenuTest.php index a2de73522258d..fdd632789db46 100644 --- a/tests/unit/suites/libraries/cms/html/JHtmlMenuTest.php +++ b/tests/unit/suites/libraries/cms/html/JHtmlMenuTest.php @@ -26,7 +26,7 @@ class JHtmlMenuTest extends TestCaseDatabase */ protected function setUp() { - // skipped because dateset that allows these test not to fail let other tests fail. + // Skipped because dataset that allows these test not to fail let other tests fail. $this->markTestSkipped('skipped RD 3.Feb 2017'); parent::setUp(); diff --git a/tests/unit/suites/libraries/cms/installer/JInstallerAdapterTest.php b/tests/unit/suites/libraries/cms/installer/JInstallerAdapterTest.php index 8374f02f8e4e4..a0f5a8a0354cd 100644 --- a/tests/unit/suites/libraries/cms/installer/JInstallerAdapterTest.php +++ b/tests/unit/suites/libraries/cms/installer/JInstallerAdapterTest.php @@ -556,7 +556,7 @@ public function testDiscoverInstallWithExceptionThrownInAdapterMethods($method) // Mock setupInstallPaths throwing an exception $object->expects($this->once()) ->method($method) - ->willThrowException(new RuntimeException()); + ->willThrowException(new RuntimeException); $manifestObject = simplexml_load_string($this->sampleManifest); unset($manifestObject->description); @@ -1036,7 +1036,7 @@ public function testInstallAbortsWhenSetupUpdatesThrowsException() // Check that setupUpdates has been called $object->expects($this->once()) ->method('setupUpdates') - ->willThrowException(new RuntimeException()); + ->willThrowException(new RuntimeException); $manifestObject = simplexml_load_string($this->sampleManifest); TestReflection::setValue($object, 'manifest', $manifestObject); @@ -1200,7 +1200,7 @@ public function testInstallWithExceptionThrownInAdapterMethods($method) // Mock setupInstallPaths throwing an exception $object->expects($this->once()) ->method($method) - ->willThrowException(new RuntimeException()); + ->willThrowException(new RuntimeException); $manifestObject = simplexml_load_string($this->sampleManifest); unset($manifestObject->description); @@ -1263,7 +1263,7 @@ public function testInstallWithExceptionThrownInFinaliseInstall() // Mock setupInstallPaths throwing an exception $object->expects($this->once()) ->method('finaliseInstall') - ->willThrowException(new RuntimeException()); + ->willThrowException(new RuntimeException); $manifestObject = simplexml_load_string($this->sampleManifest); unset($manifestObject->description); diff --git a/tests/unit/suites/libraries/cms/router/JRouterSiteTest.php b/tests/unit/suites/libraries/cms/router/JRouterSiteTest.php index d18f8d5f2deed..3128233d2b795 100644 --- a/tests/unit/suites/libraries/cms/router/JRouterSiteTest.php +++ b/tests/unit/suites/libraries/cms/router/JRouterSiteTest.php @@ -896,6 +896,7 @@ public function testParseSefRoute($url, $mode, $appConfig, $expectedParseVars, $ ->will($this->returnValue(true)); unset($appConfig['languagefilter']); } + $app->expects($this->any()) ->method('get') ->will($this->returnValueMap($appConfig)); diff --git a/tests/unit/suites/libraries/cms/router/JRouterTest.php b/tests/unit/suites/libraries/cms/router/JRouterTest.php index 91995eabc8de6..c212553b8fadf 100644 --- a/tests/unit/suites/libraries/cms/router/JRouterTest.php +++ b/tests/unit/suites/libraries/cms/router/JRouterTest.php @@ -98,7 +98,7 @@ public function testProperTypeAndMode($client) $cache->setAccessible(true); $cache->setValue(array()); - #$this->markTestSkipped('Untestable due to global instance cache not clearable.'); + // $this->markTestSkipped('Untestable due to global instance cache not clearable.'); $object = JRouter::getInstance($client, array('mode' => 'test')); @@ -131,7 +131,8 @@ public function testLegacyApplicationRouterIsStillLoaded() 'id' => 3, 'name' => 'tester', 'path' => __DIR__ . '/data' - )); + ) + ); $this->assertInstanceOf('JRouter', JRouter::getInstance('tester')); } @@ -215,10 +216,12 @@ public function testBuildGivesTheSameResultAsTheJuriConstructor($mode) { $uri = new JUri('index.php?var1=value1'); $object = new JRouter; + if (!empty($mode)) { $object->setMode($mode); } + $result = $this->object->build('index.php?var1=value1'); $this->assertEquals($uri, $result); } @@ -390,6 +393,7 @@ function (JRouter $router, JUri $uri) public function testParseRulesCanReplacePresetVariables($preset, $rules, $stage, $expected) { $this->object->setVars($preset, false); + foreach ($rules as $rule) { $this->object->attachParseRule($rule, $stage); @@ -453,6 +457,7 @@ function (JRouter $router, JUri $uri) public function testParseRulesCanAddVariables($preset, $rules, $stage, $expected) { $this->object->setVars($preset, false); + foreach ($rules as $rule) { $this->object->attachParseRule($rule, $stage); @@ -528,6 +533,7 @@ function (JRouter $router, JUri $uri) public function testFirstParseRuleTakesPrecedence($preset, $rules, $stage, $expected) { $this->object->setVars($preset, false); + foreach ($rules as $rule) { $this->object->attachParseRule($rule, $stage); diff --git a/tests/unit/suites/libraries/joomla/application/JApplicationBaseTest.php b/tests/unit/suites/libraries/joomla/application/JApplicationBaseTest.php index 9151b75bcb628..ac8c9b64dcec6 100644 --- a/tests/unit/suites/libraries/joomla/application/JApplicationBaseTest.php +++ b/tests/unit/suites/libraries/joomla/application/JApplicationBaseTest.php @@ -70,7 +70,7 @@ public function testClose() */ public function testExecute() { - // execute() has no return, just make sure the method runs + // As execute() has no return, just make sure the method runs $this->assertNull($this->class->execute()); } diff --git a/tests/unit/suites/libraries/joomla/application/JApplicationWebTest.php b/tests/unit/suites/libraries/joomla/application/JApplicationWebTest.php index aa79497da5be2..d8b1e10b7de2d 100644 --- a/tests/unit/suites/libraries/joomla/application/JApplicationWebTest.php +++ b/tests/unit/suites/libraries/joomla/application/JApplicationWebTest.php @@ -1099,9 +1099,9 @@ public function testRedirect() $this->class->headers[2] ); - $this->assertRegexp('/Expires/',$this->class->headers[3][0]); + $this->assertRegexp('/Expires/', $this->class->headers[3][0]); - $this->assertRegexp('/Last-Modified/',$this->class->headers[4][0]); + $this->assertRegexp('/Last-Modified/', $this->class->headers[4][0]); $this->assertEquals( array('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0', true, null), @@ -1167,9 +1167,9 @@ public function testRedirectWithExistingStatusCode1() $this->class->headers[3] ); - $this->assertRegexp('/Expires/',$this->class->headers[4][0]); + $this->assertRegexp('/Expires/', $this->class->headers[4][0]); - $this->assertRegexp('/Last-Modified/',$this->class->headers[5][0]); + $this->assertRegexp('/Last-Modified/', $this->class->headers[5][0]); $this->assertEquals( array('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0', true, null), @@ -1229,9 +1229,9 @@ public function testRedirectWithExistingStatusCode2() $this->class->headers[2] ); - $this->assertRegexp('/Expires/',$this->class->headers[3][0]); + $this->assertRegexp('/Expires/', $this->class->headers[3][0]); - $this->assertRegexp('/Last-Modified/',$this->class->headers[4][0]); + $this->assertRegexp('/Last-Modified/', $this->class->headers[4][0]); $this->assertEquals( array('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0', true, null), @@ -1341,9 +1341,9 @@ public function testRedirectWithMoved() $this->class->headers[2] ); - $this->assertRegexp('/Expires/',$this->class->headers[3][0]); + $this->assertRegexp('/Expires/', $this->class->headers[3][0]); - $this->assertRegexp('/Last-Modified/',$this->class->headers[4][0]); + $this->assertRegexp('/Last-Modified/', $this->class->headers[4][0]); $this->assertEquals( array('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0', true, null), diff --git a/tests/unit/suites/libraries/joomla/archive/JArchiveTest.php b/tests/unit/suites/libraries/joomla/archive/JArchiveTest.php index 2a6d0e5c8dd48..4cfdcc61dce72 100644 --- a/tests/unit/suites/libraries/joomla/archive/JArchiveTest.php +++ b/tests/unit/suites/libraries/joomla/archive/JArchiveTest.php @@ -63,7 +63,7 @@ public function testExtractGzip() $this->markTestSkipped('Gzip files can not be extracted.'); } - // we need a configuration with a tmp_path set + // We need a configuration with a tmp_path set $config = JFactory::$config; $config->set('tmp_path', __DIR__ . '/output'); @@ -83,7 +83,7 @@ public function testExtractBzip2() $this->markTestSkipped('Bzip2 files can not be extracted.'); } - // we need a configuration with a tmp_path set + // We need a configuration with a tmp_path set $config = JFactory::$config; $config->set('tmp_path', __DIR__ . '/output'); @@ -100,7 +100,6 @@ public function testExtractBzip2() */ public function testExtractUnknownType() { - JArchive::extract(__DIR__ . '/unknown.type', $this->outputPath); } diff --git a/tests/unit/suites/libraries/joomla/archive/JArchiveTestCase.php b/tests/unit/suites/libraries/joomla/archive/JArchiveTestCase.php index 3021783c5f5a7..08f9bedc18946 100644 --- a/tests/unit/suites/libraries/joomla/archive/JArchiveTestCase.php +++ b/tests/unit/suites/libraries/joomla/archive/JArchiveTestCase.php @@ -61,7 +61,7 @@ protected function tearDown() { if (is_dir($this->outputPath)) { - // delete files in output directory + // Delete files in output directory foreach (glob("{$this->outputPath}/*") as $file) { unlink($file); diff --git a/tests/unit/suites/libraries/joomla/database/JDatabaseQueryTest.php b/tests/unit/suites/libraries/joomla/database/JDatabaseQueryTest.php index 2882b54087030..4a7d86e203693 100644 --- a/tests/unit/suites/libraries/joomla/database/JDatabaseQueryTest.php +++ b/tests/unit/suites/libraries/joomla/database/JDatabaseQueryTest.php @@ -2014,7 +2014,7 @@ protected function tearDown() public function seedDateAdd() { return array( - // date, interval, datepart, expected + // Elements: date, interval, datepart, expected 'Add date' => array('2008-12-31', '1', 'DAY', "DATE_ADD('2008-12-31', INTERVAL 1 DAY)"), 'Subtract date' => array('2008-12-31', '-1', 'DAY', "DATE_ADD('2008-12-31', INTERVAL -1 DAY)"), 'Add datetime' => array('2008-12-31 23:59:59', '1', 'DAY', "DATE_ADD('2008-12-31 23:59:59', INTERVAL 1 DAY)"), diff --git a/tests/unit/suites/libraries/joomla/form/field/JFormFieldModuleLayoutTest.php b/tests/unit/suites/libraries/joomla/form/field/JFormFieldModuleLayoutTest.php index b02983f516cc2..541c879ba7853 100644 --- a/tests/unit/suites/libraries/joomla/form/field/JFormFieldModuleLayoutTest.php +++ b/tests/unit/suites/libraries/joomla/form/field/JFormFieldModuleLayoutTest.php @@ -35,7 +35,7 @@ protected function getDataSet() */ public function testGetInput() { - $field = new JFormFieldModulelayout(); + $field = new JFormFieldModulelayout; $field->setup( new SimpleXmlElement(''), 'value' diff --git a/tests/unit/suites/libraries/joomla/form/fields/JFormFieldFileListTest.php b/tests/unit/suites/libraries/joomla/form/fields/JFormFieldFileListTest.php index 153d23c75c1e4..8a4d9e2658428 100644 --- a/tests/unit/suites/libraries/joomla/form/fields/JFormFieldFileListTest.php +++ b/tests/unit/suites/libraries/joomla/form/fields/JFormFieldFileListTest.php @@ -48,6 +48,7 @@ public function testGetInput() $this->greaterThan(0), 'Line:' . __LINE__ . ' The getInput method should return something without error.' ); + // TODO: Should check all the attributes have come in properly. } } diff --git a/tests/unit/suites/libraries/joomla/github/JGithubPackageUsersTest.php b/tests/unit/suites/libraries/joomla/github/JGithubPackageUsersTest.php index 0bf60c091a499..454b90e056bdc 100644 --- a/tests/unit/suites/libraries/joomla/github/JGithubPackageUsersTest.php +++ b/tests/unit/suites/libraries/joomla/github/JGithubPackageUsersTest.php @@ -364,7 +364,7 @@ public function testEditFailure() ->with('/user', $input, 0, 0) ->will($this->returnValue($this->response)); - //$this->object->edit($name, $email, $blog, $company, $location, $hireable, $bio); + // $this->object->edit($name, $email, $blog, $company, $location, $hireable, $bio); $this->assertThat( diff --git a/tests/unit/suites/libraries/joomla/github/repositories/JGithubPackageRepositoriesDownloadsTest.php b/tests/unit/suites/libraries/joomla/github/repositories/JGithubPackageRepositoriesDownloadsTest.php index 03f2696fbca66..7e033180a7605 100644 --- a/tests/unit/suites/libraries/joomla/github/repositories/JGithubPackageRepositoriesDownloadsTest.php +++ b/tests/unit/suites/libraries/joomla/github/repositories/JGithubPackageRepositoriesDownloadsTest.php @@ -129,7 +129,7 @@ public function testUpload() ->will($this->returnValue($this->response)); $this->assertThat( - $this->object->upload('joomla', 'joomla-platform', 123, 'a/b/aaa.zip', 'acl', 201, 'aaa.zip', '123abc', '123abc', '123abc','content_type', '@aaa.zip'), + $this->object->upload('joomla', 'joomla-platform', 123, 'a/b/aaa.zip', 'acl', 201, 'aaa.zip', '123abc', '123abc', '123abc', 'content_type', '@aaa.zip'), $this->equalTo($this->response->body) ); } diff --git a/tests/unit/suites/libraries/joomla/google/JGoogleAuthOauth2Test.php b/tests/unit/suites/libraries/joomla/google/JGoogleAuthOauth2Test.php index 7df2eab521dc5..61d5763624861 100644 --- a/tests/unit/suites/libraries/joomla/google/JGoogleAuthOauth2Test.php +++ b/tests/unit/suites/libraries/joomla/google/JGoogleAuthOauth2Test.php @@ -45,7 +45,6 @@ class JGoogleAuthOauth2Test extends TestCase */ protected $object; - /** * Code that the app closes with. * diff --git a/tests/unit/suites/libraries/joomla/image/JImageTest.php b/tests/unit/suites/libraries/joomla/image/JImageTest.php index 32d066f9314e7..8d85ee4aad814 100644 --- a/tests/unit/suites/libraries/joomla/image/JImageTest.php +++ b/tests/unit/suites/libraries/joomla/image/JImageTest.php @@ -384,7 +384,7 @@ public function testToFileInvalid() */ public function testToFileGif() { - $outFileGif = JPATH_TESTS . '/tmp/' . uniqid() .'.gif'; + $outFileGif = JPATH_TESTS . '/tmp/' . uniqid() . '.gif'; $image = new JImageInspector($this->testFile); $image->toFile($outFileGif, IMAGETYPE_GIF); @@ -419,7 +419,7 @@ public function testToFileGif() */ public function testToFilePng() { - $outFilePng = JPATH_TESTS . '/tmp/' . uniqid() .'.png'; + $outFilePng = JPATH_TESTS . '/tmp/' . uniqid() . '.png'; $image = new JImageInspector($this->testFile); $image->toFile($outFilePng, IMAGETYPE_PNG); @@ -455,7 +455,7 @@ public function testToFilePng() public function testToFileJpg() { // Write the file out to a JPG. - $outFileJpg = JPATH_TESTS . '/tmp/' . uniqid() .'.jpg'; + $outFileJpg = JPATH_TESTS . '/tmp/' . uniqid() . '.jpg'; $image = new JImageInspector($this->testFile); $image->toFile($outFileJpg, IMAGETYPE_JPEG); @@ -490,7 +490,7 @@ public function testToFileJpg() public function testToFileDefault() { // Write the file out to a JPG. - $outFileDefault = JPATH_TESTS . '/tmp/' . uniqid() .'.default'; + $outFileDefault = JPATH_TESTS . '/tmp/' . uniqid() . '.default'; $image = new JImageInspector($this->testFile); $image->toFile($outFileDefault); diff --git a/tests/unit/suites/libraries/joomla/input/JInputCliTest.php b/tests/unit/suites/libraries/joomla/input/JInputCliTest.php index e78f85faa61c6..bfba9751a083f 100644 --- a/tests/unit/suites/libraries/joomla/input/JInputCliTest.php +++ b/tests/unit/suites/libraries/joomla/input/JInputCliTest.php @@ -73,7 +73,7 @@ public function provider_parseArguments() { return array( - // php test.php --foo --bar=baz + // Represents: php test.php --foo --bar=baz array( array('test.php', '--foo', '--bar=baz'), array( @@ -83,7 +83,7 @@ public function provider_parseArguments() array() ), - // php test.php -abc + // Represents: php test.php -abc array( array('test.php', '-abc'), array( @@ -94,7 +94,7 @@ public function provider_parseArguments() array() ), - // php test.php arg1 arg2 arg3 + // Represents: php test.php arg1 arg2 arg3 array( array('test.php', 'arg1', 'arg2', 'arg3'), array(), @@ -105,7 +105,7 @@ public function provider_parseArguments() ) ), - // php test.php plain-arg --foo --bar=baz --funny="spam=eggs" --also-funny=spam=eggs \ + // Represents: php test.php plain-arg --foo --bar=baz --funny="spam=eggs" --also-funny=spam=eggs \ // 'plain arg 2' -abc -k=value "plain arg 3" --s="original" --s='overwrite' --s array( array('test.php', 'plain-arg', '--foo', '--bar=baz', '--funny=spam=eggs', '--also-funny=spam=eggs', @@ -128,7 +128,7 @@ public function provider_parseArguments() ) ), - // php test.php --key value -abc not-c-value + // Represents: php test.php --key value -abc not-c-value array( array('test.php', '--key', 'value', '-abc', 'not-c-value'), array( @@ -142,7 +142,7 @@ public function provider_parseArguments() ) ), - // php test.php --key1 value1 -a --key2 -b b-value --c + // Represents: php test.php --key1 value1 -a --key2 -b b-value --c array( array('test.php', '--key1', 'value1', '-a', '--key2', '-b', 'b-value', '--c'), array( diff --git a/tests/unit/suites/libraries/joomla/session/handler/array.php b/tests/unit/suites/libraries/joomla/session/handler/array.php index efab71fd9bdc9..a71d793b16e0a 100644 --- a/tests/unit/suites/libraries/joomla/session/handler/array.php +++ b/tests/unit/suites/libraries/joomla/session/handler/array.php @@ -80,11 +80,13 @@ public function setSessionData(array $array) */ public function start() { - if ($this->started && !$this->closed) { + if ($this->started && !$this->closed) + { return true; } - if (empty($this->id)) { + if (empty($this->id)) + { $this->setId($this->generateId()); } @@ -149,7 +151,8 @@ public function getId() */ public function setId($id) { - if ($this->started) { + if ($this->started) + { throw new LogicException('Cannot set session ID after the session has started.'); } @@ -202,10 +205,12 @@ public function setName($name) */ public function save() { - if (!$this->started || $this->closed) { + if (!$this->started || $this->closed) + { throw new \RuntimeException("Trying to save a session that was not started yet or was already closed"); } - // nothing to do since we don't persist the session data + + // Nothing to do since we don't persist the session data $this->closed = false; $this->started = false; } @@ -219,7 +224,7 @@ public function save() */ public function clear() { - // clear out the session + // Clear out the session $this->data = array(); } diff --git a/tests/unit/suites/libraries/joomla/user/JUserHelperTest.php b/tests/unit/suites/libraries/joomla/user/JUserHelperTest.php index ab5a354f4adbd..ae44fed4df8be 100644 --- a/tests/unit/suites/libraries/joomla/user/JUserHelperTest.php +++ b/tests/unit/suites/libraries/joomla/user/JUserHelperTest.php @@ -357,6 +357,7 @@ public function testVerifyPassword() ); $password = 'mySuperSecretPassword'; + // Generate the old style password hash used before phpass was implemented. $salt = JUserHelper::genRandomPassword(32); $crypted = JUserHelper::getCryptedPassword($password, $salt); @@ -520,7 +521,8 @@ public function testGetCryptedPassword() */ public function testGetCryptedPasswordWithMhash() { - if (!function_exists('mhash')) { + if (!function_exists('mhash')) + { $this->markTestSkipped('The mhash function is not available'); } diff --git a/tests/unit/suites/libraries/joomla/view/JViewHtmlTest.php b/tests/unit/suites/libraries/joomla/view/JViewHtmlTest.php index 3354787e155b7..7c50de3cf06e8 100644 --- a/tests/unit/suites/libraries/joomla/view/JViewHtmlTest.php +++ b/tests/unit/suites/libraries/joomla/view/JViewHtmlTest.php @@ -111,7 +111,8 @@ public function testGetPath() $this->assertEquals(realpath(__DIR__ . '/layouts1/peter.php'), $this->_instance->getPath('peter')); $this->assertEquals(realpath(__DIR__ . '/layouts2/fauxlivia.php'), $this->_instance->getPath('fauxlivia')); $this->assertEquals(realpath(__DIR__ . '/layouts1/fringe/division.php'), $this->_instance->getPath('fringe/division')); - //$this->assertEquals(realpath(__DIR__ . '/layouts1/astrid.phtml'), $this->_instance->getPath('astrid', 'phtml')); + + // $this->assertEquals(realpath(__DIR__ . '/layouts1/astrid.phtml'), $this->_instance->getPath('astrid', 'phtml')); $this->assertFalse($this->_instance->getPath('walter')); // Check dirty path. diff --git a/tests/unit/suites/plugins/content/emailcloak/PlgContentEmailcloakTest.php b/tests/unit/suites/plugins/content/emailcloak/PlgContentEmailcloakTest.php index 12f29b441a7bf..7ce4c4b31af8a 100644 --- a/tests/unit/suites/plugins/content/emailcloak/PlgContentEmailcloakTest.php +++ b/tests/unit/suites/plugins/content/emailcloak/PlgContentEmailcloakTest.php @@ -38,7 +38,7 @@ public function setup() JFactory::$application = $this->getMockCmsApp(); JFactory::$session = $this->getMockSession(); - // force the cloak JS inline so that we can unit test it easier than messing with script head in document + // Force the cloak JS inline so that we can unit test it easier than messing with script head in document JFactory::getApplication()->input->server->set('HTTP_X_REQUESTED_WITH', 'xmlhttprequest'); /** @@ -84,7 +84,7 @@ public function dataTestOnContentPrepare() */ 'this should not be parsed as it has no (at) sign in it - see what I did there? ;)', - // this third row is the full output of the cloak with inline javascript mode enabled + // This third row is the full output of the cloak with inline javascript mode enabled '' ), @@ -356,64 +356,58 @@ public function dataTestOnContentPrepare() /** * Tests PlgContentEmailcloakTest::_cloak() * - * @param string $input The text to test. - * @param string $expected The expectation of the filtering. + * @param string $input The text to test. + * @param string $expectedHTML The expectation of the filtering. + * @param string $expectedJs The expected javascript * * @return void * * @dataProvider dataTestOnContentPrepare * @since 3.6.2 */ - public function testOnContentPrepareWithRowNoFinder($input, $expectedHTML = NULL, $expectedJs) + public function testOnContentPrepareWithRowNoFinder($input, $expectedHTML, $expectedJs) { $row = new \stdClass; $row->text = $input; $params = new JRegistry; - // assert we have the correct event + // Assert we have the correct event $this->assertInstanceOf('PlgContentEmailcloak', $this->class); - // assert that we are getting a clean process + // Assert that we are getting a clean process $res = $this->class->onContentPrepare('com_content.article', $row, $params); $this->assertEquals(1, $res); - // Get the md5 hash preg_match("/addy_text([0-9a-z]{32})/", $row->text, $output_array); // If we did some cloaking then test the JS - if (count($output_array)) { + if (count($output_array)) + { $hash = $output_array[1]; - // assert the JLIB_HTML_CLOAKING span is intact + // Assert the JLIB_HTML_CLOAKING span is intact $this->assertRegExp('/\JLIB_HTML_CLOAKING\<\/span\>/', $row->text); $cloakHTML = 'JLIB_HTML_CLOAKING'; $this->assertContains($cloakHTML, $row->text); + // Need to do this to overcome whitespace comparison issue in phpunit for some reason... + preg_match_all("/\