/
dimamir
/
Wsdl_PackageGenerator
Обзор
Документация
Войти
/
dimamir
/
Wsdl_PackageGenerator
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
tests/File/Validation/MaxOccursRuleTest.php
144 строки
5 KB
Mikaël DELSOL
issue #274 - Fix validation on scalar contained by array
20 фев 2023, 19:55
Не верифицирован
20 фев 2023, 19:55
a31d48e
Код
Авторство
О чём код?
<?php declare(strict_types=1); namespace WsdlToPhp\PackageGenerator\Tests\File\Validation; use StructType\ApiParagraphType; /** * @internal * @coversDefaultClass */ final class MaxOccursRuleTest extends AbstractRule { /** * The TaxDescription * Meta informations extracted from the WSDL * - documentation: Text description of the taxes in a given language. * - maxOccurs: 5 * - minOccurs: 0. */ public function testSetTaxDescriptionWithTooManyItemsMustThrowAnException(): void { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Invalid count of 6, the number of elements contained by the property must be less than or equal to 5'); $instance = self::getWhlTaxTypeInstance(); $instance->setTaxDescription([ new ApiParagraphType(), new ApiParagraphType(), new ApiParagraphType(), new ApiParagraphType(), new ApiParagraphType(), new ApiParagraphType(), ]); } /** * The TaxDescription * Meta informations extracted from the WSDL * - documentation: Text description of the taxes in a given language. * - maxOccurs: 5 * - minOccurs: 0. */ public function testSetTaxDescriptionWithSameItemsMustPass(): void { $instance = self::getWhlTaxTypeInstance(); $this->assertSame($instance, $instance->setTaxDescription([ new ApiParagraphType(), new ApiParagraphType(), new ApiParagraphType(), new ApiParagraphType(), new ApiParagraphType(), ])); } /** * The TaxDescription * Meta informations extracted from the WSDL * - documentation: Text description of the taxes in a given language. * - maxOccurs: 5 * - minOccurs: 0. */ public function testSetTaxDescriptionWithLessItemsMustPass(): void { $instance = self::getWhlTaxTypeInstance(); $this->assertSame($instance, $instance->setTaxDescription([ new ApiParagraphType(), new ApiParagraphType(), ])); } /** * The TaxDescription * Meta informations extracted from the WSDL * - documentation: Text description of the taxes in a given language. * - maxOccurs: 5 * - minOccurs: 0. */ public function testAddToTaxDescriptionWithTooManyItemsMustThrowAnException(): void { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('You can\'t add anymore element to this property that already contains 5 elements, the number of elements contained by the property must be less than or equal to 5'); // true to ensure to start from zero for addTo calls $instance = self::getWhlTaxTypeInstance(true); $instance ->addToTaxDescription(new ApiParagraphType()) ->addToTaxDescription(new ApiParagraphType()) ->addToTaxDescription(new ApiParagraphType()) ->addToTaxDescription(new ApiParagraphType()) ->addToTaxDescription(new ApiParagraphType()) ->addToTaxDescription(new ApiParagraphType()) ->addToTaxDescription(new ApiParagraphType()) ; } /** * The TaxDescription * Meta informations extracted from the WSDL * - documentation: Text description of the taxes in a given language. * - maxOccurs: 5 * - minOccurs: 0. */ public function testAddToTaxDescriptionWithSameItemsMustPass(): void { // true to ensure to start from zero for addTo calls $instance = self::getWhlTaxTypeInstance(true); $this->assertSame( $instance, $instance ->addToTaxDescription(new ApiParagraphType()) ->addToTaxDescription(new ApiParagraphType()) ->addToTaxDescription(new ApiParagraphType()) ->addToTaxDescription(new ApiParagraphType()) ->addToTaxDescription(new ApiParagraphType()) ); } /** * The TaxDescription * Meta informations extracted from the WSDL * - documentation: Text description of the taxes in a given language. * - maxOccurs: 5 * - minOccurs: 0. */ public function testAddToTaxDescriptionWithLessItemsMustPass(): void { // true to ensure to start from zero for addTo calls $instance = self::getWhlTaxTypeInstance(true); $this->assertSame( $instance, $instance ->addToTaxDescription(new ApiParagraphType()) ->addToTaxDescription(new ApiParagraphType()) ); } }