William Cheng 6434c86afd
[php-nextgen] add php-nextgen client generator (#16480)
* php-nextgen first commit

* [php] Set minimal PHP version to ^8.0 (#14500)

* Set minimal PHP version to ^8.0

* Fix php-nextgen config

* Change stability to BETA

* Add phplint package (#15054)

* [php-nextgen] Rename folders to follow PDS skeleton (#15102)

* Change lib -> src, test -> tests folder

This will make build compliant to PHP-PDS skeleton.
Ref: https://github.com/php-pds/skeleton

* Refresh samples

* Exclude composer.lock from codebase (#15105)

Since client generator is library and not a project it makes sense
to exclude composer.lock from codebase by default.

Ref: http://getcomposer.org/doc/02-libraries.md#lock-file

* Add @generated tag to DocBlocks (#15106)

This tag in draft status right now(PSR-19), but I think we can leverage
from it already.

Ref: https://github.com/php-fig/fig-standards/blob/master/proposed/phpdoc-tags.md#55-generated

* update samples, doc

* update samples

---------

Co-authored-by: Yuriy Belenko <yura-bely@mail.ru>
2023-09-03 16:16:58 +08:00

58 lines
1.7 KiB
PHP

<?php
namespace OpenAPI\Client;
use OpenAPI\Client\Model\EnumTest;
use PHPUnit\Framework\TestCase;
class EnumTestTest extends TestCase
{
public function testPossibleValues()
{
$this->assertSame(EnumTest::ENUM_STRING_UPPER, "UPPER");
$this->assertSame(EnumTest::ENUM_STRING_LOWER, "lower");
$this->assertSame(EnumTest::ENUM_INTEGER_1, 1);
$this->assertSame(EnumTest::ENUM_INTEGER_MINUS_1, -1);
$this->assertSame(EnumTest::ENUM_NUMBER_1_DOT_1, 1.1);
$this->assertSame(EnumTest::ENUM_NUMBER_MINUS_1_DOT_2, -1.2);
}
public function testStrictValidation()
{
$enum = new EnumTest([
'enum_string' => 0,
]);
$this->assertFalse($enum->valid());
$expected = [
"invalid value '0' for 'enum_string', must be one of 'UPPER', 'lower', ''",
"'enum_string_required' can't be null",
];
$this->assertSame($expected, $enum->listInvalidProperties());
}
public function testThrowExceptionWhenInvalidAmbiguousValueHasPassed()
{
$this->expectException(\InvalidArgumentException::class);
$enum = new EnumTest();
$enum->setEnumString(0);
}
public function testNonRequiredPropertyIsOptional()
{
$enum = new EnumTest([
'enum_string_required' => 'UPPER',
]);
$this->assertSame([], $enum->listInvalidProperties());
$this->assertTrue($enum->valid());
}
public function testRequiredProperty()
{
$enum = new EnumTest();
$this->assertSame(["'enum_string_required' can't be null"], $enum->listInvalidProperties());
$this->assertFalse($enum->valid());
}
}