api/symfony/Component/Validator/Tests/Constraints/IsbnValidatorTest.yaml

108 lines
5.3 KiB
YAML
Raw Permalink Normal View History

2024-09-26 09:03:21 +00:00
name: IsbnValidatorTest
class_comment: '# * @see https://en.wikipedia.org/wiki/Isbn'
dependencies:
- name: Isbn
type: class
source: Symfony\Component\Validator\Constraints\Isbn
- name: IsbnValidator
type: class
source: Symfony\Component\Validator\Constraints\IsbnValidator
- name: UnexpectedValueException
type: class
source: Symfony\Component\Validator\Exception\UnexpectedValueException
- name: ConstraintValidatorTestCase
type: class
source: Symfony\Component\Validator\Test\ConstraintValidatorTestCase
properties: []
methods:
- name: testValidIsbn10
visibility: public
parameters:
- name: isbn
comment: "# * @see https://en.wikipedia.org/wiki/Isbn\n# */\n# class IsbnValidatorTest\
\ extends ConstraintValidatorTestCase\n# {\n# protected function createValidator():\
\ IsbnValidator\n# {\n# return new IsbnValidator();\n# }\n# \n# public static\
\ function getValidIsbn10()\n# {\n# return [\n# ['2723442284'],\n# ['2723442276'],\n\
# ['2723455041'],\n# ['2070546810'],\n# ['2711858839'],\n# ['2756406767'],\n#\
\ ['2870971648'],\n# ['226623854X'],\n# ['2851806424'],\n# ['0321812700'],\n#\
\ ['0-45122-5244'],\n# ['0-4712-92311'],\n# ['0-9752298-0-X'],\n# ];\n# }\n# \n\
# public static function getInvalidIsbn10()\n# {\n# return [\n# ['27234422841',\
\ Isbn::TOO_LONG_ERROR],\n# ['272344228', Isbn::TOO_SHORT_ERROR],\n# ['0-4712-9231',\
\ Isbn::TOO_SHORT_ERROR],\n# ['1234567890', Isbn::CHECKSUM_FAILED_ERROR],\n# ['0987656789',\
\ Isbn::CHECKSUM_FAILED_ERROR],\n# ['7-35622-5444', Isbn::CHECKSUM_FAILED_ERROR],\n\
# ['0-4X19-92611', Isbn::CHECKSUM_FAILED_ERROR],\n# ['0_45122_5244', Isbn::INVALID_CHARACTERS_ERROR],\n\
# ['2870#971#648', Isbn::INVALID_CHARACTERS_ERROR],\n# ['0-9752298-0-x', Isbn::INVALID_CHARACTERS_ERROR],\n\
# ['1A34567890', Isbn::INVALID_CHARACTERS_ERROR],\n# // chr(1) evaluates to 0\n\
# // 2070546810 is valid\n# ['2'.\\chr(1).'70546810', Isbn::INVALID_CHARACTERS_ERROR],\n\
# ];\n# }\n# \n# public static function getValidIsbn13()\n# {\n# return [\n# ['978-2723442282'],\n\
# ['978-2723442275'],\n# ['978-2723455046'],\n# ['978-2070546817'],\n# ['978-2711858835'],\n\
# ['978-2756406763'],\n# ['978-2870971642'],\n# ['978-2266238540'],\n# ['978-2851806420'],\n\
# ['978-0321812704'],\n# ['978-0451225245'],\n# ['978-0471292319'],\n# ];\n# }\n\
# \n# public static function getInvalidIsbn13()\n# {\n# return [\n# ['978-27234422821',\
\ Isbn::TOO_LONG_ERROR],\n# ['978-272344228', Isbn::TOO_SHORT_ERROR],\n# ['978-2723442-82',\
\ Isbn::TOO_SHORT_ERROR],\n# ['978-2723442281', Isbn::CHECKSUM_FAILED_ERROR],\n\
# ['978-0321513774', Isbn::CHECKSUM_FAILED_ERROR],\n# ['979-0431225385', Isbn::CHECKSUM_FAILED_ERROR],\n\
# ['980-0474292319', Isbn::CHECKSUM_FAILED_ERROR],\n# ['0-4X19-92619812', Isbn::INVALID_CHARACTERS_ERROR],\n\
# ['978_2723442282', Isbn::INVALID_CHARACTERS_ERROR],\n# ['978#2723442282', Isbn::INVALID_CHARACTERS_ERROR],\n\
# ['978-272C442282', Isbn::INVALID_CHARACTERS_ERROR],\n# // chr(1) evaluates to\
\ 0\n# // 978-2070546817 is valid\n# ['978-2'.\\chr(1).'70546817', Isbn::INVALID_CHARACTERS_ERROR],\n\
# ];\n# }\n# \n# public static function getValidIsbn()\n# {\n# return array_merge(\n\
# self::getValidIsbn10(),\n# self::getValidIsbn13()\n# );\n# }\n# \n# public static\
\ function getInvalidIsbn()\n# {\n# return array_merge(\n# self::getInvalidIsbn10(),\n\
# self::getInvalidIsbn13()\n# );\n# }\n# \n# public function testNullIsValid()\n\
# {\n# $constraint = new Isbn(true);\n# \n# $this->validator->validate(null, $constraint);\n\
# \n# $this->assertNoViolation();\n# }\n# \n# public function testEmptyStringIsValid()\n\
# {\n# $constraint = new Isbn(true);\n# \n# $this->validator->validate('', $constraint);\n\
# \n# $this->assertNoViolation();\n# }\n# \n# public function testExpectsStringCompatibleType()\n\
# {\n# $this->expectException(UnexpectedValueException::class);\n# $constraint\
\ = new Isbn(true);\n# \n# $this->validator->validate(new \\stdClass(), $constraint);\n\
# }\n# \n# /**\n# * @dataProvider getValidIsbn10"
- name: testInvalidIsbn10
visibility: public
parameters:
- name: isbn
- name: code
comment: '# * @dataProvider getInvalidIsbn10'
- name: testInvalidIsbn10Named
visibility: public
parameters: []
comment: null
- name: testValidIsbn13
visibility: public
parameters:
- name: isbn
comment: '# * @dataProvider getValidIsbn13'
- name: testInvalidIsbn13
visibility: public
parameters:
- name: isbn
- name: code
comment: '# * @dataProvider getInvalidIsbn13'
- name: testInvalidIsbn13Named
visibility: public
parameters: []
comment: null
- name: testValidIsbnAny
visibility: public
parameters:
- name: isbn
comment: '# * @dataProvider getValidIsbn'
- name: testInvalidIsbnAnyIsbn10
visibility: public
parameters:
- name: isbn
- name: code
comment: '# * @dataProvider getInvalidIsbn10'
- name: testInvalidIsbnAnyIsbn13
visibility: public
parameters:
- name: isbn
- name: code
comment: '# * @dataProvider getInvalidIsbn13'
traits:
- Symfony\Component\Validator\Constraints\Isbn
- Symfony\Component\Validator\Constraints\IsbnValidator
- Symfony\Component\Validator\Exception\UnexpectedValueException
- Symfony\Component\Validator\Test\ConstraintValidatorTestCase
interfaces: []