public function test_move_topic() { $this->login(); $this->load_ids(array('forums' => array('Prune Shadow'), 'topics' => array('Prune Shadow #1'))); $crawler = self::request('GET', "mcp.php?f={$this->data['forums']['Prune Shadow']}&i=main&action=move&mode=forum_view&start=0&topic_id_list[]={$this->data['topics']['Prune Shadow #1']}&sid={$this->sid}"); $form = $crawler->selectButton('confirm')->form(array('to_forum_id' => 2, 'move_leave_shadow' => true)); $crawler = self::submit($form); $this->assert_forum_details($this->data['forums']['Prune Shadow'], array('forum_posts_approved' => 0, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 0, 'forum_topics_approved' => 1, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0), 'after moving'); $this->db = $this->get_db(); // Date topic 3 days back $sql = 'UPDATE phpbb_topics SET topic_last_post_time = ' . (time() - 60 * 60 * 24 * 3) . ' WHERE topic_id = ' . ($this->data['topics']['Prune Shadow #1'] + 1); $result = $this->db->sql_query($sql); $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', "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, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 0, 'forum_topics_approved' => 0, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0), 'after the cron job'); }
public function test_double_unlock() { $this->assertTrue($this->lock->acquire()); $this->assertTrue($this->lock->owns_lock()); $this->assertFalse(empty($this->config['test_lock']), 'First lock is acquired'); $this->lock->release(); $this->assertFalse($this->lock->owns_lock()); $this->assertEquals('0', $this->config['test_lock'], 'First lock is released'); $lock2 = new \phpbb\lock\db('test_lock', $this->config, $this->db); $this->assertTrue($lock2->acquire()); $this->assertTrue($lock2->owns_lock()); $this->assertFalse(empty($this->config['test_lock']), 'Second lock is acquired'); $this->lock->release(); $this->assertTrue($lock2->owns_lock()); $this->assertFalse(empty($this->config['test_lock']), 'Double release of first lock is ignored'); $lock2->release(); $this->assertEquals('0', $this->config['test_lock'], 'Second lock is released'); }