Created
April 6, 2012 03:15
-
-
Save k-holy/2316522 to your computer and use it in GitHub Desktop.
thisisaverylonghostnamewhichextendstwohundredfiftysixcharactersandthereforshouldnotbeallowedbythisvalidatorbecauserfc3986limitstheallowedcharacterstoalimitoftwohunderedfiftysixcharactersinsumbutifthistestwouldfailthenitshouldreturntruewhichthrowsanexcepti
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @group ZF-10267 | |
*/ | |
public function testURI() | |
{ | |
$valuesExpected = array( | |
array(Hostname::ALLOW_URI, true, array('localhost', 'example.com', '~ex%20ample')), | |
array(Hostname::ALLOW_URI, false, array('§bad', 'don?t.know', 'thisisaverylonghostnamewhichextendstwohundredfiftysixcharactersandthereforshouldnotbeallowedbythisvalidatorbecauserfc3986limitstheallowedcharacterstoalimitoftwohunderedfiftysixcharactersinsumbutifthistestwouldfailthenitshouldreturntruewhichthrowsanexceptionbytheunittest')), | |
); | |
foreach ($valuesExpected as $element) { | |
$validator = new Hostname($element[0]); | |
foreach ($element[2] as $input) { | |
$this->assertEquals($element[1], $validator->isValid($input), implode("\n", $validator->getMessages()) . $input); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this is a very long host name which extends two hundred fifty six characters and there for should not be allowed by this validator because rfc3986 limits the allowed characters to a limit of two hundered fifty six characters in sum but if this test would fail then it should return true which throws an exception by the unit test
ドメイン名が255文字以内ってテストかな。自分のバリデーションライブラリのURIチェックでは書式しか見てないわ…
文字数はDBのカラム定義に合わせて別途チェックしてるから実用上問題はないけど
あ、gistのdescriptionでも255文字で切られてるな