forked from loafle/openapi-generator-original
* 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>
39 lines
1.1 KiB
PHP
39 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace OpenAPI\Client;
|
|
|
|
use InvalidArgumentException;
|
|
use OpenAPI\Client\Model\Name;
|
|
use OpenAPI\Client\Model\NullableClass;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
/**
|
|
* class NullableTest
|
|
*
|
|
* @package OpenAPI\Client
|
|
*/
|
|
class NullableTest extends TestCase
|
|
{
|
|
public function testNotNullableException(): void
|
|
{
|
|
$name = new Name();
|
|
$name->setName(1);
|
|
$this->assertEquals(1, $name->getName(), 'Non-nullable property can be set and retains its value');
|
|
|
|
$this->expectException(InvalidArgumentException::class);
|
|
$this->expectExceptionMessage('non-nullable name cannot be null');
|
|
|
|
$name->setName(null);
|
|
}
|
|
|
|
public function testNullableobject(): void
|
|
{
|
|
$nullable = new NullableClass();
|
|
|
|
$nullable->setIntegerProp(null);
|
|
$this->assertNull($nullable->getIntegerProp(), 'Nullable property can be set to null retains its value');
|
|
|
|
$nullable->setIntegerProp(1);
|
|
$this->assertEquals(1, $nullable->getIntegerProp(), 'Nullable property can be set and retains its value');
|
|
}
|
|
} |