forked from loafle/openapi-generator-original
* Bump minimum required version to PHP7.1 ref: http://php.net/supported-versions.php * Bump phpunit * Update [api|model]_test.mustache * Update samples bin/openapi3/php-petstore.sh * Update namespace of PHPUnit ("tests" folder) * `setExpectedException` is deleted in PHPUnit 7.4 * Update namespace of "Assert" class * The attribute 'name' is required * Add anotation to exclude the test from risky testcheck * Update samples (samples/client/petstore/php) * Apply updates to "test" in openapi2 folder (samples/client/petstore/php)b3495ecbfe
15e00ae89d
2fc6917d13
0d016c00ed
* Install php7.1 * Switch to php7 * Update samples (security) bin/security/php-petstore.sh
60 lines
1.7 KiB
PHP
60 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 for 'enum_string', must be one of 'UPPER', 'lower', ''",
|
|
"'enum_string_required' can't be null",
|
|
];
|
|
$this->assertSame($expected, $enum->listInvalidProperties());
|
|
}
|
|
|
|
/**
|
|
* @expectedException \InvalidArgumentException
|
|
*/
|
|
public function testThrowExceptionWhenInvalidAmbiguousValueHasPassed()
|
|
{
|
|
$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());
|
|
}
|
|
}
|