Skip to content

Commit fc3db88

Browse files
committed
Code cleanup
1 parent 31c12d7 commit fc3db88

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

src/Exceptions/FallbackResolverException.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
class FallbackResolverException extends Exception
88
{
99
protected const int UNABLE_TO_FIND_RESOLVER_CLASS = 0;
10-
protected const int UNABLE_TO_RESOLVE_DEFAULT_VALUE = 1;
1110

1211
public static function unableToFindResolverClass(string $resolverClass): self
1312
{
@@ -16,12 +15,4 @@ public static function unableToFindResolverClass(string $resolverClass): self
1615
self::UNABLE_TO_FIND_RESOLVER_CLASS
1716
);
1817
}
19-
20-
public static function unableToResolveDefaultValue(): self
21-
{
22-
return new self(
23-
'Unable to resolve default value',
24-
self::UNABLE_TO_RESOLVE_DEFAULT_VALUE
25-
);
26-
}
2718
}

tests/Unit/Concerns/EmptyDataTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Nuxtifyts\PhpDto\Contracts\EmptyData as EmptyDataContract;
99
use Nuxtifyts\PhpDto\Data;
1010
use Nuxtifyts\PhpDto\Enums\Property\Type;
11+
use Nuxtifyts\PhpDto\Exceptions\DataCreationException;
1112
use Nuxtifyts\PhpDto\Tests\Dummies\AddressData;
1213
use Nuxtifyts\PhpDto\Tests\Dummies\CountryData;
1314
use Nuxtifyts\PhpDto\Tests\Dummies\Enums\YesNoBackedEnum;
@@ -27,6 +28,7 @@
2728
#[CoversClass(Data::class)]
2829
#[CoversClass(PropertyContext::class)]
2930
#[CoversClass(ClassContext::class)]
31+
#[CoversClass(DataCreationException::class)]
3032
#[UsesClass(ArrayOfScalarTypes::class)]
3133
#[UsesClass(PointGroupData::class)]
3234
#[UsesClass(PointData::class)]
@@ -167,4 +169,24 @@ public function __construct(
167169
],
168170
];
169171
}
172+
173+
/**
174+
* @throws Throwable
175+
*/
176+
#[Test]
177+
public function will_throw_exception_when_parameter_is_not_linked_to_a_property(): void
178+
{
179+
$object = new readonly class('') extends Data {
180+
public string $otherPropertyName;
181+
182+
public function __construct(
183+
string $parameterName
184+
) {
185+
$this->otherPropertyName = $parameterName;
186+
}
187+
};
188+
189+
self::expectException(DataCreationException::class);
190+
$object::empty();
191+
}
170192
}

0 commit comments

Comments
 (0)