forked from loafle/openapi-generator-original
* Set PHP 7.2 as minimum version * Update PHPUnit to 8 || 9 * Set Bionic environment in Travis config * PHPUnit 8 requires void return in static methods * PHPUnit 8 requires void return in static methods * Fix curl exception message test When I run "curl http://wrong_host.zxc" output is: curl: (6) Could not resolve host: wrong_host.zxc Maybe this message is different across versions. Tested curl version: curl 7.54.0 (x86_64-apple-darwin18.0) libcurl/7.54.0 LibreSSL/2.6.5 zlib/1.2.11 nghttp2/1.24.1 * Update assertions of deprecated assertInternalType * Migrate to expectException method of PHPUnit 8 * Fix PHPCS Fixer errors * Replace deprecated 'assertRegExp' assertion * Exclude PHPUnit and php-cs-fixer cache * Refresh samples * Set root Travis CI environment to PHP 7.2.5 * Change to 7.3 as 7.2.27 is highest preinstalled * Fix testWrongHost test
58 lines
1.7 KiB
PHP
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 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());
|
|
}
|
|
}
|