Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save k-holy/2316522 to your computer and use it in GitHub Desktop.
Save k-holy/2316522 to your computer and use it in GitHub Desktop.
thisisaverylonghostnamewhichextendstwohundredfiftysixcharactersandthereforshouldnotbeallowedbythisvalidatorbecauserfc3986limitstheallowedcharacterstoalimitoftwohunderedfiftysixcharactersinsumbutifthistestwouldfailthenitshouldreturntruewhichthrowsanexcepti
<?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);
}
}
}
@k-holy
Copy link
Author

k-holy commented Apr 6, 2012

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文字で切られてるな

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment