From d5801333f7c3724c82057eeccf522cf32c6a253b Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 6 Sep 2014 17:16:56 +0200 Subject: [PATCH] [ticket/12983] Do not test invalid values until Symfony 2.4 PHPBB3-12983 --- tests/functional/ucp_preferences_test.php | 36 +++++++++++++++++------ 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/tests/functional/ucp_preferences_test.php b/tests/functional/ucp_preferences_test.php index c904f5af06..7ef325dc4b 100644 --- a/tests/functional/ucp_preferences_test.php +++ b/tests/functional/ucp_preferences_test.php @@ -16,7 +16,7 @@ */ class phpbb_functional_ucp_preferences_test extends phpbb_functional_test_case { - public function test_submitting_profile_info() + public function test_submitting_preferences_view() { $this->add_lang('ucp'); $this->login(); @@ -35,26 +35,44 @@ class phpbb_functional_ucp_preferences_test extends phpbb_functional_test_case $crawler = self::submit($form); $this->assertContainsLang('PREFERENCES_UPDATED', $crawler->filter('#message')->text()); + } + + public function test_submitting_invalid_preferences_view() + { + $this->add_lang('ucp'); + $this->login(); $crawler = self::request('GET', 'ucp.php?i=ucp_prefs&mode=view'); $this->assertContainsLang('UCP_PREFS_VIEW', $crawler->filter('#cp-main h2')->text()); + $form = $crawler->selectButton('Submit')->form(); - $form = $crawler->selectButton('Submit')->form(array( - 'topic_sk' => 'z', - 'topic_sd' => 'z', - 'topic_st' => 'test', - 'post_sk' => 'z', - 'post_sd' => 'z', - 'post_st' => 'test', - )); + if (!method_exists($form, 'disableValidation')) + { + $this->markTestIncomplete('The crawler cannot select invalid values, until Symfony 2.4!'); + } + + $form = $form->disableValidation(); + $form['topic_sk']->select('z'); + $form['topic_sd']->select('z'); + $form['topic_st']->select('test'); + $form['post_sk']->select('z'); + $form['post_sd']->select('z'); + $form['post_st']->select('test'); $crawler = self::submit($form); $this->assertContainsLang('WRONG_DATA_POST_SD', $crawler->filter('#cp-main')->text()); $this->assertContainsLang('WRONG_DATA_POST_SK', $crawler->filter('#cp-main')->text()); $this->assertContainsLang('WRONG_DATA_TOPIC_SD', $crawler->filter('#cp-main')->text()); $this->assertContainsLang('WRONG_DATA_TOPIC_SK', $crawler->filter('#cp-main')->text()); + } + + public function test_read_preferences_view() + { + $this->add_lang('ucp'); + $this->login(); $crawler = self::request('GET', 'ucp.php?i=ucp_prefs&mode=view'); + $this->assertContainsLang('UCP_PREFS_VIEW', $crawler->filter('#cp-main h2')->text()); $form = $crawler->selectButton('Submit')->form(); $this->assertEquals('a', $form->get('topic_sk')->getValue());