-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
160 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace DoclerLabs\ApiClientGenerator\Test\Unit\Entity; | ||
|
||
use DoclerLabs\ApiClientGenerator\Entity\FieldType; | ||
use InvalidArgumentException; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* @coversDefaultClass FieldType | ||
*/ | ||
class FieldTypeTest extends TestCase | ||
{ | ||
public function testStatic(): void | ||
{ | ||
self::assertTrue(FieldType::isSpecificationTypeString('string')); | ||
self::assertTrue(FieldType::isSpecificationTypeMixed(null)); | ||
self::assertTrue(FieldType::isSpecificationTypeArray('array')); | ||
self::assertTrue(FieldType::isSpecificationTypeFloat('number')); | ||
self::assertTrue(FieldType::isSpecificationTypeBoolean('boolean')); | ||
self::assertTrue(FieldType::isSpecificationTypeInteger('integer')); | ||
self::assertTrue(FieldType::isSpecificationTypeObject('object')); | ||
} | ||
|
||
public function testIsString(): void | ||
{ | ||
$sut = new FieldType(FieldType::SPEC_TYPE_STRING); | ||
self::assertTrue($sut->isString()); | ||
self::assertEquals(FieldType::PHP_TYPE_STRING, $sut->toPhpType()); | ||
self::assertEquals(FieldType::SPEC_TYPE_STRING, $sut->toSpecificationType()); | ||
} | ||
|
||
public function testIsMixed(): void | ||
{ | ||
$sut = new FieldType(null); | ||
self::assertTrue($sut->isMixed()); | ||
self::assertEquals('', $sut->toPhpType()); | ||
self::assertEquals(null, $sut->toSpecificationType()); | ||
} | ||
|
||
public function testIsFloat(): void | ||
{ | ||
$sut = new FieldType(FieldType::SPEC_TYPE_FLOAT); | ||
self::assertTrue($sut->isFloat()); | ||
self::assertEquals(FieldType::PHP_TYPE_FLOAT, $sut->toPhpType()); | ||
self::assertEquals(FieldType::SPEC_TYPE_FLOAT, $sut->toSpecificationType()); | ||
} | ||
|
||
public function testIsInteger(): void | ||
{ | ||
$sut = new FieldType(FieldType::SPEC_TYPE_INTEGER); | ||
self::assertTrue($sut->isInteger()); | ||
self::assertEquals(FieldType::PHP_TYPE_INTEGER, $sut->toPhpType()); | ||
self::assertEquals(FieldType::SPEC_TYPE_INTEGER, $sut->toSpecificationType()); | ||
} | ||
|
||
public function testIsObject(): void | ||
{ | ||
$sut = new FieldType(FieldType::SPEC_TYPE_OBJECT); | ||
self::assertTrue($sut->isObject()); | ||
self::assertEquals(FieldType::PHP_TYPE_OBJECT, $sut->toPhpType()); | ||
self::assertEquals(FieldType::SPEC_TYPE_OBJECT, $sut->toSpecificationType()); | ||
} | ||
|
||
public function testIsBoolean(): void | ||
{ | ||
$sut = new FieldType(FieldType::SPEC_TYPE_BOOLEAN); | ||
self::assertTrue($sut->isBoolean()); | ||
self::assertEquals(FieldType::PHP_TYPE_BOOLEAN, $sut->toPhpType()); | ||
self::assertEquals(FieldType::SPEC_TYPE_BOOLEAN, $sut->toSpecificationType()); | ||
} | ||
|
||
public function testIsArray(): void | ||
{ | ||
$sut = new FieldType(FieldType::SPEC_TYPE_ARRAY); | ||
self::assertTrue($sut->isArray()); | ||
self::assertEquals(FieldType::PHP_TYPE_ARRAY, $sut->toPhpType()); | ||
self::assertEquals(FieldType::SPEC_TYPE_ARRAY, $sut->toSpecificationType()); | ||
} | ||
|
||
public function testInvalidType(): void | ||
{ | ||
$this->expectException(InvalidArgumentException::class); | ||
new FieldType('invalid'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.