From baef26f7ed44ada30c3ed345035d2b4d7cea3a2f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 5 May 2014 18:16:50 +0200 Subject: [PATCH 1/6] [ticket/12503] All tests should extend \phpbb_test_case PHPBB3-12503 --- tests/avatar/manager_test.php | 2 +- tests/bbcode/parser_test.php | 2 +- tests/class_loader/class_loader_test.php | 2 +- tests/cron/manager_test.php | 2 +- tests/passwords/drivers_test.php | 2 +- tests/passwords/manager_test.php | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php index 527bb223d5..01c058a1bd 100644 --- a/tests/avatar/manager_test.php +++ b/tests/avatar/manager_test.php @@ -9,7 +9,7 @@ require_once dirname(__FILE__) . '/driver/foobar.php'; -class phpbb_avatar_manager_test extends PHPUnit_Framework_TestCase +class phpbb_avatar_manager_test extends \phpbb_test_case { public function setUp() { diff --git a/tests/bbcode/parser_test.php b/tests/bbcode/parser_test.php index d0dcce5bbf..4bf5037f45 100644 --- a/tests/bbcode/parser_test.php +++ b/tests/bbcode/parser_test.php @@ -12,7 +12,7 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/bbcode.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/message_parser.php'; -class phpbb_bbcode_parser_test extends PHPUnit_Framework_TestCase +class phpbb_bbcode_parser_test extends \phpbb_test_case { public function bbcode_firstpass_data() { diff --git a/tests/class_loader/class_loader_test.php b/tests/class_loader/class_loader_test.php index 6e551f658a..d3c7bb0579 100644 --- a/tests/class_loader/class_loader_test.php +++ b/tests/class_loader/class_loader_test.php @@ -7,7 +7,7 @@ * */ -class phpbb_class_loader_test extends PHPUnit_Framework_TestCase +class phpbb_class_loader_test extends \phpbb_test_case { public function setUp() { diff --git a/tests/cron/manager_test.php b/tests/cron/manager_test.php index 713f44c1e2..937add252f 100644 --- a/tests/cron/manager_test.php +++ b/tests/cron/manager_test.php @@ -14,7 +14,7 @@ require_once dirname(__FILE__) . '/tasks/simple_ready.php'; require_once dirname(__FILE__) . '/tasks/simple_not_runnable.php'; require_once dirname(__FILE__) . '/tasks/simple_should_not_run.php'; -class phpbb_cron_manager_test extends PHPUnit_Framework_TestCase +class phpbb_cron_manager_test extends \phpbb_test_case { public function setUp() { diff --git a/tests/passwords/drivers_test.php b/tests/passwords/drivers_test.php index 40bb110185..df1474419b 100644 --- a/tests/passwords/drivers_test.php +++ b/tests/passwords/drivers_test.php @@ -7,7 +7,7 @@ * */ -class phpbb_passwords_helper_test extends PHPUnit_Framework_TestCase +class phpbb_passwords_helper_test extends \phpbb_test_case { public function setUp() { diff --git a/tests/passwords/manager_test.php b/tests/passwords/manager_test.php index 008f222696..f38b31e843 100644 --- a/tests/passwords/manager_test.php +++ b/tests/passwords/manager_test.php @@ -7,7 +7,7 @@ * */ -class phpbb_passwords_manager_test extends PHPUnit_Framework_TestCase +class phpbb_passwords_manager_test extends \phpbb_test_case { protected $passwords_drivers; From e9dabb0903cfd58678fcbdd42e68faec0c86ccd2 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 5 May 2014 18:18:48 +0200 Subject: [PATCH 2/6] [ticket/12486] Rename data provider to fix "Risky" from phpunit PHPBB3-12486 --- tests/passwords/manager_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/passwords/manager_test.php b/tests/passwords/manager_test.php index f38b31e843..561c4d1189 100644 --- a/tests/passwords/manager_test.php +++ b/tests/passwords/manager_test.php @@ -176,7 +176,7 @@ class phpbb_passwords_manager_test extends \phpbb_test_case } } - public function test_combined_hash_data() + public function combined_hash_data() { if (version_compare(PHP_VERSION, '5.3.7', '<')) { @@ -242,7 +242,7 @@ class phpbb_passwords_manager_test extends \phpbb_test_case } /** - * @dataProvider test_combined_hash_data + * @dataProvider combined_hash_data */ public function test_combined_hash_password($first_type, $second_type, $expected = true) { From fe99e60d827ba34dbc4bc5cbb7dd9368164ceed3 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 5 May 2014 18:21:28 +0200 Subject: [PATCH 3/6] [ticket/12486] Make assertion on the return to remove "Risky" from phpunit PHPBB3-12486 --- tests/cache/null_driver_test.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/cache/null_driver_test.php b/tests/cache/null_driver_test.php index 58e57f2b3a..049d0412b6 100644 --- a/tests/cache/null_driver_test.php +++ b/tests/cache/null_driver_test.php @@ -35,14 +35,12 @@ class phpbb_cache_null_driver_test extends phpbb_database_test_case public function test_purge() { - // does nothing - $this->driver->purge(); + $this->assertNull($this->driver->purge()); } public function test_destroy() { - // does nothing - $this->driver->destroy('foo'); + $this->assertNull($this->driver->destroy('foo')); } public function test_cache_sql() From 5d8d42d88a43576771be3dd0d7562e15b694d653 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 5 May 2014 18:25:44 +0200 Subject: [PATCH 4/6] [ticket/12504] Remove unused request object from avatar manager test PHPBB3-12504 --- tests/avatar/manager_test.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php index 01c058a1bd..870e909e26 100644 --- a/tests/avatar/manager_test.php +++ b/tests/avatar/manager_test.php @@ -23,7 +23,6 @@ class phpbb_avatar_manager_test extends \phpbb_test_case // Prepare dependencies for avatar manager and driver $config = new \phpbb\config\config(array()); - $request = $this->getMock('\phpbb\request\request'); $cache = $this->getMock('\phpbb\cache\driver\driver_interface'); $path_helper = new \phpbb\path_helper( new \phpbb\symfony_request( From f27e4a44b85909fe0d93afc55e4266bd6d927fba Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 5 May 2014 18:27:00 +0200 Subject: [PATCH 5/6] [ticket/12504] Use defined variables PHPBB3-12504 --- tests/avatar/manager_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php index 870e909e26..7e78201b2f 100644 --- a/tests/avatar/manager_test.php +++ b/tests/avatar/manager_test.php @@ -29,8 +29,8 @@ class phpbb_avatar_manager_test extends \phpbb_test_case new phpbb_mock_request() ), new \phpbb\filesystem(), - $this->phpbb_root_path, - $this->phpEx + $phpbb_root_path, + $phpEx ); // $this->avatar_foobar will be needed later on From d9de4fc72c82ff1eb3ac5cbe64259a2bc0405037 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 5 May 2014 18:31:01 +0200 Subject: [PATCH 6/6] [ticket/12504] Use local variables where possible PHPBB3-12504 --- tests/avatar/manager_test.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php index 7e78201b2f..69d4280b9a 100644 --- a/tests/avatar/manager_test.php +++ b/tests/avatar/manager_test.php @@ -11,13 +11,18 @@ require_once dirname(__FILE__) . '/driver/foobar.php'; class phpbb_avatar_manager_test extends \phpbb_test_case { + /** @var \phpbb\avatar\manager */ + protected $manager; + protected $avatar_foobar; + protected $avatar_barfoo; + public function setUp() { global $phpbb_root_path, $phpEx; // Mock phpbb_container - $this->phpbb_container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); - $this->phpbb_container->expects($this->any()) + $phpbb_container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $phpbb_container->expects($this->any()) ->method('get') ->will($this->returnArgument(0)); @@ -59,7 +64,7 @@ class phpbb_avatar_manager_test extends \phpbb_test_case $config['allow_avatar_' . get_class($this->avatar_barfoo)] = false; // Set up avatar manager - $this->manager = new \phpbb\avatar\manager($config, $avatar_drivers, $this->phpbb_container); + $this->manager = new \phpbb\avatar\manager($config, $avatar_drivers, $phpbb_container); } protected function avatar_drivers() @@ -221,8 +226,6 @@ class phpbb_avatar_manager_test extends \phpbb_test_case */ public function test_clean_row(array $input, array $output, $prefix = '') { - $cleaned_row = array(); - $cleaned_row = \phpbb\avatar\manager::clean_row($input, $prefix); foreach ($output as $key => $value) {