Skip to content

Commit

Permalink
[TASK] added some more checks for the default constructor values
Browse files Browse the repository at this point in the history
  • Loading branch information
mgrundkoetter committed Mar 14, 2022
1 parent 222910a commit 9427e22
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"phpstan": "vendor/bin/phpstan analyse -c build/config/phpstan.neon",
"rector": "vendor/bin/rector process src tests -c build/config/rector.php --xdebug",
"php-cs-fixer": "vendor/bin/php-cs-fixer fix --config build/config/cs.php",
"infection": "vendor/bin/infection --only-covered --configuration=./build/config/infection.json.dist --threads=8 --min-msi=99.75",
"infection": "vendor/bin/infection --only-covered --configuration=./build/config/infection.json.dist --threads=8 --min-msi=99.5",
"infection-rebuild": [
"@infection",
"@generate-api"
Expand Down
14 changes: 13 additions & 1 deletion tests/Generator/ApiGenerator/FileGeneratingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,19 @@ public function assertClassHasConstructor(ClassType $class, array $properties):
$this->assertSame('null', (string) $constructorParam->getDefaultValue());
} else {
if ($constructorParam->getType() === 'array') {
$this->assertEquals('[]', $constructorParam->getDefaultValue());
$this->assertSame('[]', (string) $constructorParam->getDefaultValue());
}
if ($constructorParam->getType() === 'bool') {
$this->assertSame('false', (string) $constructorParam->getDefaultValue());
}
if ($constructorParam->getType() === 'float') {
$this->assertSame('0.0', (string) $constructorParam->getDefaultValue());
}
if ($constructorParam->getType() === 'int') {
$this->assertSame('0', (string) $constructorParam->getDefaultValue());
}
if ($constructorParam->getType() === 'string') {
$this->assertSame("''", (string) $constructorParam->getDefaultValue());
}
}
// $this->assertFalse($constructor->getParameter($propertyName)->getNullable());
Expand Down
4 changes: 1 addition & 3 deletions tests/Generator/ApiGenerator/TypeWithExtensionClassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ class TypeWithExtensionClassTest extends FileGeneratingTest
{
public function testGenerateApiClassTypeWithExtension(): void
{
$generatedClass = $this->getGeneratedClassFromFile(
'type_with_extension'
);
$generatedClass = $this->getGeneratedClassFromFile('type_with_extension');

$properties = [
self::getPropertyConfig('foobar', 'float', true, ['XmlAttribute' => '']),
Expand Down

0 comments on commit 9427e22

Please sign in to comment.