diff --git a/tests/event/listener_test.php b/tests/event/listener_test.php index 88159e9..c4497da 100644 --- a/tests/event/listener_test.php +++ b/tests/event/listener_test.php @@ -240,10 +240,10 @@ public function test_configure_media_embed($tag, $code, $id, $exists, $parse_url */ public function exception_errors_data() { - return array( - array('notok', '\Symfony\Component\Yaml\Exception\ParseException'), // Exception when custom site YAML is invalid - array('invalid', '\InvalidArgumentException'), // Exception when MediaEmbed can't process the site definition - ); + return [ + ['notok', '\Symfony\Component\Yaml\Exception\ParseException'], // Exception when custom site YAML is invalid + ['invalid', '\InvalidArgumentException'], // Exception when MediaEmbed can't process the site definition + ]; } /** diff --git a/tests/functional/media_embed_test.php b/tests/functional/media_embed_test.php index 90bdb76..a54961e 100644 --- a/tests/functional/media_embed_test.php +++ b/tests/functional/media_embed_test.php @@ -27,9 +27,9 @@ public function test_posting_media_bbcode() { $this->login(); - $post = $this->create_topic(2, 'Media Embed Test Topic 1', "[media]https://youtu.be/{$this->youtubeId}[/media]"); - $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}"); - self::assertStringContainsString("//www.youtube.com/embed/{$this->youtubeId}", $crawler->filter("#post_content{$post['topic_id']} iframe")->attr('src')); + $post = $this->create_topic(2, 'Media Embed Test Topic 1', "[media]https://youtu.be/$this->youtubeId[/media]"); + $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid=$this->sid"); + self::assertStringContainsString("//www.youtube.com/embed/$this->youtubeId", $crawler->filter("#post_content{$post['topic_id']} iframe")->attr('src')); } public function test_posting_custom_site() @@ -37,32 +37,32 @@ public function test_posting_custom_site() $this->login(); $this->admin_login(); - $crawler = self::request('GET', "adm/index.php?i=\\phpbb\\mediaembed\\acp\\main_module&mode=manage&sid={$this->sid}"); + $crawler = self::request('GET', "adm/index.php?i=\\phpbb\\mediaembed\\acp\\main_module&mode=manage&sid=$this->sid"); $this->assert_checkbox_is_unchecked($crawler, 'ok'); $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); $fields = $form->all(); // Tick all the check boxes dang it, because unticked boxes can't be crawled alone foreach ($fields as $fieldname => $fieldobject) { - if (preg_match('/mark\[(\d+)\]/', $fieldname, $matches)) + if (preg_match('/mark\[(\d+)]/', $fieldname, $matches)) { $form['mark'][$matches[1]]->tick(); } } self::submit($form); - $crawler = self::request('GET', "adm/index.php?i=\\phpbb\\mediaembed\\acp\\main_module&mode=manage&sid={$this->sid}"); + $crawler = self::request('GET', "adm/index.php?i=\\phpbb\\mediaembed\\acp\\main_module&mode=manage&sid=$this->sid"); $this->assert_checkbox_is_checked($crawler, 'ok'); - $post = $this->create_topic(2, 'Media Embed Custom Site Test Topic 1', "[media]https://ok.ru/video/{$this->ok_ru_Id}[/media]"); - $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}"); - self::assertStringContainsString("//ok.ru/videoembed/{$this->ok_ru_Id}", $crawler->filter("#post_content{$post['topic_id']} iframe")->attr('src')); + $post = $this->create_topic(2, 'Media Embed Custom Site Test Topic 1', "[media]https://ok.ru/video/$this->ok_ru_Id[/media]"); + $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid=$this->sid"); + self::assertStringContainsString("//ok.ru/videoembed/$this->ok_ru_Id", $crawler->filter("#post_content{$post['topic_id']} iframe")->attr('src')); } public function signatures_data() { return [ [false, 'UNAUTHORISED_BBCODE'], - [true, "//www.youtube.com/embed/{$this->youtubeId}"], + [true, "//www.youtube.com/embed/$this->youtubeId"], ]; } @@ -87,7 +87,7 @@ public function test_signatures($allowed, $expected) $crawler = self::request('GET', 'ucp.php?i=ucp_profile&mode=signature'); $form = $crawler->selectButton('Submit')->form([ - 'signature' => "[media]https://youtu.be/{$this->youtubeId}[/media]", + 'signature' => "[media]https://youtu.be/$this->youtubeId[/media]", ]); $crawler = self::submit($form); @@ -112,9 +112,9 @@ public function test_posting_media_bbcode_wo_permission() $this->admin_login(); // Set f_mediaembed to never - $crawler = self::request('GET', "adm/index.php?i=acp_permissions&icat=16&mode=setting_forum_local&forum_id[0]=2&group_id[0]=2&sid={$this->sid}"); + $crawler = self::request('GET', "adm/index.php?i=acp_permissions&icat=16&mode=setting_forum_local&forum_id[0]=2&group_id[0]=2&sid=$this->sid"); $form = $crawler->selectButton($this->lang('APPLY_PERMISSIONS'))->form(); - $data = array('setting[2][2][f_mediaembed]' => ACL_NEVER); + $data = ['setting[2][2][f_mediaembed]' => ACL_NEVER]; $form->setValues($data); self::submit($form); @@ -130,7 +130,7 @@ public function test_media_embed_help() $this->assertContainsLang('HELP_EMBEDDING_MEDIA', $crawler->filter('#faqlinks')->text()); preg_match('/https:\/\/youtu\.be\/(.*)/', $this->lang('HELP_EMBEDDING_MEDIA_DEMO'), $matches); - self::assertStringContainsString("//www.youtube.com/embed/{$matches[1]}", $crawler->filter('body iframe')->attr('src')); + self::assertStringContainsString("//www.youtube.com/embed/$matches[1]", $crawler->filter('body iframe')->attr('src')); } public function test_acp_modules() @@ -141,7 +141,7 @@ public function test_acp_modules() $this->admin_login(); // Test settings module width error - $crawler = self::request('GET', "adm/index.php?i=\\phpbb\\mediaembed\\acp\\main_module&mode=settings&sid={$this->sid}"); + $crawler = self::request('GET', "adm/index.php?i=\\phpbb\\mediaembed\\acp\\main_module&mode=settings&sid=$this->sid"); $this->assertContainsLang('ACP_MEDIA_SETTINGS', $crawler->filter('#main')->text(), 'The Media Embed settings module failed to load'); $form_data = [ 'media_embed_max_width' => "vimo:100px\nyoutube:100", @@ -153,7 +153,7 @@ public function test_acp_modules() self::assertStringContainsString($this->lang('ACP_MEDIA_INVALID_SITE', 'vimo', '100px') . '
' . $this->lang('ACP_MEDIA_INVALID_WIDTH', 'youtube', '100'), $crawler->filter('.errorbox')->html()); // Test settings module width success - $crawler = self::request('GET', "adm/index.php?i=\\phpbb\\mediaembed\\acp\\main_module&mode=settings&sid={$this->sid}"); + $crawler = self::request('GET', "adm/index.php?i=\\phpbb\\mediaembed\\acp\\main_module&mode=settings&sid=$this->sid"); $this->assertContainsLang('ACP_MEDIA_SETTINGS', $crawler->filter('#main')->text(), 'The Media Embed settings module failed to load'); $form_data = [ 'media_embed_max_width' => "vimeo:100px\nyoutube:100%", @@ -164,7 +164,7 @@ public function test_acp_modules() self::assertGreaterThan(0, $crawler->filter('.successbox')->count()); // Test manage sites module - $crawler = self::request('GET', "adm/index.php?i=\\phpbb\\mediaembed\\acp\\main_module&mode=manage&sid={$this->sid}"); + $crawler = self::request('GET', "adm/index.php?i=\\phpbb\\mediaembed\\acp\\main_module&mode=manage&sid=$this->sid"); $this->assertContainsLang('ACP_MEDIA_MANAGE', $crawler->filter('#main')->text(), 'The Media Embed settings module failed to load'); $this->assert_checkbox_is_checked($crawler, 'youtube');