Skip to content

Commit

Permalink
[general] Use global date provider for doctrine timestampable (#310)
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Aug 29, 2024
1 parent 0e147df commit 69879db
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 31 deletions.
2 changes: 0 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,11 @@
"contributte/translation": "^2.0",
"cweagans/composer-patches": "^1.7",
"fastybird/application-library": "dev-main",
"fastybird/datetime-factory": "^0.6",
"fastybird/exchange-library": "dev-main",
"fastybird/json-api": "^0.19",
"fastybird/metadata-library": "dev-main",
"fastybird/simple-auth": "^0.14",
"fastybird/tools-library": "dev-main",
"ipub/doctrine-timestampable": "^2.0",
"ipub/slim-router": "^0.2",
"nettrine/dbal": "^0.8",
"nettrine/orm": "^0.8",
Expand Down
14 changes: 14 additions & 0 deletions tests/cases/unit/BaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use FastyBird\DateTimeFactory;
use FastyBird\Library\Application\Boot as ApplicationBoot;
use FastyBird\Library\Application\Exceptions as ApplicationExceptions;
use FastyBird\Library\Application\Utilities as ApplicationUtilities;
use FastyBird\Module\Ui\DI;
use Nette;
use PHPUnit\Framework\TestCase;
Expand Down Expand Up @@ -43,6 +44,19 @@ protected function setUp(): void
DateTimeFactory\Factory::class,
$dateTimeFactory,
);

$dateTimeProvider = $this->createMock(ApplicationUtilities\DateTimeProvider::class);
$dateTimeProvider
->method('getDate')
->willReturn($dateTimeFactory->getNow());
$dateTimeProvider
->method('getTimestamp')
->willReturn($dateTimeFactory->getNow()->getTimestamp());

$this->mockContainerService(
ApplicationUtilities\DateTimeProvider::class,
$dateTimeProvider,
);
}

/**
Expand Down
14 changes: 14 additions & 0 deletions tests/cases/unit/DbTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use FastyBird\DateTimeFactory;
use FastyBird\Library\Application\Boot as ApplicationBoot;
use FastyBird\Library\Application\Exceptions as ApplicationExceptions;
use FastyBird\Library\Application\Utilities as ApplicationUtilities;
use FastyBird\Module\Ui\DI;
use FastyBird\Module\Ui\Exceptions;
use IPub\DoctrineCrud;
Expand Down Expand Up @@ -86,6 +87,19 @@ public function setUp(): void
DateTimeFactory\Factory::class,
$dateTimeFactory,
);

$dateTimeProvider = $this->createMock(ApplicationUtilities\DateTimeProvider::class);
$dateTimeProvider
->method('getDate')
->willReturn($dateTimeFactory->getNow());
$dateTimeProvider
->method('getTimestamp')
->willReturn($dateTimeFactory->getNow()->getTimestamp());

$this->mockContainerService(
ApplicationUtilities\DateTimeProvider::class,
$dateTimeProvider,
);
}

protected function registerDatabaseSchemaFile(string $file): void
Expand Down
2 changes: 0 additions & 2 deletions tests/common.neon
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ services:
setup:
- addMiddleware(@fbJsonApi.middlewares.jsonapi)

- {factory: FastyBird\Module\Ui\Tests\Tools\DateTimeProvider}

cache.storage: Nette\Caching\Storages\DevNullStorage

contributteTranslation:
Expand Down
27 changes: 0 additions & 27 deletions tests/tools/DateTimeProvider.php

This file was deleted.

0 comments on commit 69879db

Please sign in to comment.