Skip to content

Commit

Permalink
[Tests] Added ClockMock to make time-sensitive tests more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
mnocon committed Sep 10, 2020
1 parent 0d9b6b7 commit db36af5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"phpspec/phpspec": "^5.1.2",
"ezsystems/ezplatform-code-style": "^0.1.0",
"friendsofphp/php-cs-fixer": "^2.16.1",
"memio/spec-gen": "^0.9.0"
"memio/spec-gen": "^0.9.0",
"symfony/phpunit-bridge": "^5.1"
},
"autoload": {
"psr-4": {
Expand Down
4 changes: 4 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@
>
<php>
<ini name="error_reporting" value="-1" />
<env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled=1"/>
</php>
<testsuites>
<testsuite name="default"><directory>tests</directory></testsuite>
</testsuites>
<listeners>
<listener class="\Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
</listeners>
</phpunit>
15 changes: 3 additions & 12 deletions tests/PurgeClient/LocalPurgeClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,6 @@
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
namespace EzSystems\PlatformHttpCacheBundle\Tests\PurgeClient;

/**
* Avoid test failure caused by time passing between generating expected & actual object.
*
* @return int
*/
function time()
{
return 1417624982;
}

namespace eZ\Publish\Core\MVC\Symfony\Cache\Tests;

use EzSystems\PlatformHttpCacheBundle\RequestAwarePurger;
Expand All @@ -25,6 +13,9 @@ function time()

class LocalPurgeClientTest extends TestCase
{
/**
* @group time-sensitive
*/
public function testPurge()
{
$locationIds = [123, 456, 789];
Expand Down

0 comments on commit db36af5

Please sign in to comment.