Skip to content

Commit

Permalink
test: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
EdieLemoine committed Sep 11, 2024
1 parent 554f51f commit c3a0d95
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/Pdk/Audit/Repository/WcPdkAuditRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
use MyParcelNL\Pdk\Storage\Contract\StorageInterface;
use MyParcelNL\WooCommerce\Database\Contract\WpDatabaseServiceInterface;

final class WcPdkAuditRepository extends Repository implements PdkAuditRepositoryInterface
/**
* @final
*/
class WcPdkAuditRepository extends Repository implements PdkAuditRepositoryInterface
{
/**
* @var \MyParcelNL\WooCommerce\Database\Contract\WpDatabaseServiceInterface
Expand Down
16 changes: 16 additions & 0 deletions tests/Mock/MockWcPdkAuditRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

namespace MyParcelNL\WooCommerce\Tests\Mock;

use MyParcelNL\WooCommerce\Pdk\Audit\Repository\WcPdkAuditRepository;
use Symfony\Contracts\Service\ResetInterface;

final class MockWcPdkAuditRepository extends WcPdkAuditRepository implements ResetInterface
{
public function reset(): void
{
$this->storage->delete('audits');
}
}
2 changes: 2 additions & 0 deletions tests/Mock/MockWcPdkBootstrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use MyParcelNL\Pdk\Base\Concern\PdkInterface;
use MyParcelNL\WooCommerce\Database\Contract\WpDatabaseServiceInterface;
use MyParcelNL\WooCommerce\Pdk\Audit\Repository\WcPdkAuditRepository;
use MyParcelNL\WooCommerce\Pdk\WcPdkBootstrapper;
use function DI\get;

Expand Down Expand Up @@ -98,6 +99,7 @@ protected function getAdditionalConfig(
self::$config,
[
WpDatabaseServiceInterface::class => get(MockWpDatabaseService::class),
WcPdkAuditRepository::class => get(MockWcPdkAuditRepository::class),
]
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@
'orderIds' => [$wcOrder->get_id()],
]);

/** @var \MyParcelNL\Pdk\Audit\Contract\PdkAuditRepositoryInterface $auditRepository */
/** @var \MyParcelNL\WooCommerce\Tests\Mock\MockWcPdkAuditRepository $auditRepository */
$auditRepository = Pdk::get(PdkAuditRepositoryInterface::class);

// Clear the cache of retrieved audits
$auditRepository->reset();

$audit = $auditRepository->all()
->first();

Expand Down

0 comments on commit c3a0d95

Please sign in to comment.