From 7a173877b7244f4ab6a8ff7b6fa0d6450027751b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Bartus?= Date: Fri, 18 Mar 2016 22:57:02 +0100 Subject: [ticket/14542] Move cron to controller PHPBB3-14542 --- tests/functional/controllers_compatibility_test.php | 8 ++++++++ tests/functional/prune_shadow_topic_test.php | 11 ++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'tests/functional') diff --git a/tests/functional/controllers_compatibility_test.php b/tests/functional/controllers_compatibility_test.php index 9499888a1a..36a34aa7c8 100644 --- a/tests/functional/controllers_compatibility_test.php +++ b/tests/functional/controllers_compatibility_test.php @@ -37,6 +37,13 @@ class phpbb_functional_controllers_compatibility_test extends phpbb_functional_t $this->assert301('feed.php?t=1', 'app.php/feed/topic/1'); } + public function test_cron_compatibility() + { + $this->assert301('cron.php?cron_type=foo', 'app.php/cron/foo'); + $this->assert301('cron.php?cron_type=foo&bar=foobar', 'app.php/cron/foo?bar=foobar'); + $this->assert301('cron.php?cron_type=foo&bar=foobar&who=me', 'app.php/cron/foo?bar=foobar&who=me'); + } + protected function assert301($from, $to) { self::$client->followRedirects(false); @@ -44,6 +51,7 @@ class phpbb_functional_controllers_compatibility_test extends phpbb_functional_t // Fix sid issues $location = self::$client->getResponse()->getHeader('Location'); + $location = str_replace('&', '&', $location); $location = preg_replace('#sid=[^&]+(&(amp;)?)?#', '', $location); if (substr($location, -1) === '?') { diff --git a/tests/functional/prune_shadow_topic_test.php b/tests/functional/prune_shadow_topic_test.php index c014119b98..39bf223f93 100644 --- a/tests/functional/prune_shadow_topic_test.php +++ b/tests/functional/prune_shadow_topic_test.php @@ -130,7 +130,16 @@ class phpbb_functional_prune_shadow_topic_test extends phpbb_functional_test_cas $crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Prune Shadow']}&sid={$this->sid}"); $this->assertNotEmpty($crawler->filter('img')->last()->attr('src')); - self::request('GET', "cron.php?cron_type=cron.task.core.prune_shadow_topics&f={$this->data['forums']['Prune Shadow']}&sid={$this->sid}", array(), false); + self::request('GET', "app.php/cron/cron.task.core.prune_shadow_topics?f={$this->data['forums']['Prune Shadow']}&sid={$this->sid}", array(), false); + + // Try to ensure that the cron can actually run before we start to wait for it + sleep(1); + $cron_lock = new \phpbb\lock\db('cron_lock', new \phpbb\config\db($this->db, new \phpbb\cache\driver\dummy(), 'phpbb_config'), $this->db); + while (!$cron_lock->acquire()) + { + // do nothing + } + $cron_lock->release(); $this->assert_forum_details($this->data['forums']['Prune Shadow'], array( 'forum_posts_approved' => 0, -- cgit v1.2.1