/** * @dataProvider addURLProvider */ public function testAddURL($get_params, $post_params, $should_throw_exception, $contains) { if ($should_throw_exception) { $this->setExpectedException('fValidationException'); } $_GET = array_merge($_GET, $get_params); $_POST = array_merge($_POST, $post_params); try { $v = new fValidation(); $v->addURLFields('foo'); $v->validate(); } catch (fValidationException $e) { foreach ($contains as $string) { $this->assertContains($string, $e->getMessage()); } throw $e; } }
public function testAddURL6() { $this->setExpectedException('fValidationException'); $_POST['foo'] = "http://flourishlib.com/foo bar/"; $_GET['bar'] = "http://flourishlib.com/foo bar/"; try { $v = new fValidation(); $v->addURLFields('foo', 'bar'); $v->validate(); } catch (fValidationException $e) { $this->assertContains('Foo: Please enter a URL in the form http://www.example.com/page', $e->getMessage()); $this->assertContains('Bar: Please enter a URL in the form http://www.example.com/page', $e->getMessage()); throw $e; } }