Skip to content

Commit 7d6db8b

Browse files
committed
Refactored DateDimensionTest
1 parent 217b834 commit 7d6db8b

File tree

1 file changed

+12
-56
lines changed

1 file changed

+12
-56
lines changed

tests/Integration/Entity/DateDimensionTest.php

Lines changed: 12 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@
99
namespace App\Tests\Integration\Entity;
1010

1111
use App\Entity\DateDimension;
12-
use App\Utils\Tests\PhpUnitUtil;
12+
use DateTime;
1313
use DateTimeImmutable;
14-
use Throwable;
15-
use function in_array;
16-
use function ucfirst;
14+
use DateTimeZone;
1715

1816
/**
1917
* Class DateDimensionTest
@@ -29,59 +27,17 @@ class DateDimensionTest extends EntityTestCase
2927
* @var class-string
3028
*/
3129
protected string $entityName = DateDimension::class;
32-
33-
/** @noinspection PhpMissingParentCallCommonInspection */
34-
/**
35-
* @testdox No setter for `$property` property in read only entity - so cannot test this
36-
*/
37-
public function testThatSetterOnlyAcceptSpecifiedType(
38-
?string $property = null,
39-
?string $type = null,
40-
?array $meta = null,
41-
): void {
42-
self::markTestSkipped('There is not setter in read only entity...');
43-
}
44-
45-
/** @noinspection PhpMissingParentCallCommonInspection */
46-
/**
47-
* @testdox No setter for `$property` property in read only entity - so cannot test this
48-
*/
49-
public function testThatSetterReturnsInstanceOfEntity(
50-
?string $property = null,
51-
?string $type = null,
52-
?array $meta = null
53-
): void {
54-
self::markTestSkipped('There is not setter in read only entity...');
55-
}
56-
57-
/** @noinspection PhpMissingParentCallCommonInspection */
58-
/**
59-
* @dataProvider dataProviderTestThatSetterAndGettersWorks
60-
*
61-
* @throws Throwable
62-
*
63-
* @testdox Test that getter method for `$type $property` property returns expected
64-
*/
65-
public function testThatGetterReturnsExpectedValue(string $property, string $type, array $meta): void
30+
31+
public function testThatGetCreatedAtMethodReturnsExpected(): void
6632
{
67-
$getter = 'get' . ucfirst($property);
68-
69-
if (in_array($type, [PhpUnitUtil::TYPE_BOOL, PhpUnitUtil::TYPE_BOOLEAN], true)) {
70-
$getter = 'is' . ucfirst($property);
71-
}
72-
73-
$dateDimension = $this->createEntity();
74-
75-
try {
76-
$method = 'assertIs' . ucfirst($type);
77-
78-
self::$method($dateDimension->{$getter}());
79-
} catch (Throwable $error) {
80-
/**
81-
* @var class-string $type
82-
*/
83-
self::assertInstanceOf($type, $dateDimension->{$getter}(), $error->getMessage());
84-
}
33+
$entity = $this->createEntity();
34+
$createdAt = $entity->getCreatedAt();
35+
36+
self::assertEqualsWithDelta(
37+
(new DateTime('now', new DateTimeZone('utc')))->getTimestamp(),
38+
$createdAt->getTimestamp(),
39+
1
40+
);
8541
}
8642

8743
/**

0 commit comments

Comments
 (0)