Navigation Menu

Skip to content

Commit

Permalink
minor #19544 [Cache] Skip tests that sleep() but can't be clock-mocke…
Browse files Browse the repository at this point in the history
…d (nicolas-grekas)

This PR was merged into the 3.1 branch.

Discussion
----------

[Cache] Skip tests that sleep() but can't be clock-mocked

| Q             | A
| ------------- | ---
| Branch?       | 3.1
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Skip tests that require real calls to `sleep()`: they slow down the test suite too much and don't test much.
`@group time-sensitive` tests will run these test cases just fine, but they can't be used on tests that use an external source for time, i.e. for redis or apcu.

Commits
-------

d476725 [Cache] Skip tests that sleep() but can't be clock-mocked
  • Loading branch information
nicolas-grekas committed Aug 5, 2016
2 parents c45b916 + d476725 commit 49a2cb8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
Expand Up @@ -15,6 +15,12 @@

abstract class AbstractRedisAdapterTest extends AdapterTestCase
{
protected $skippedTests = array(
'testExpiration' => 'Testing expiration slows down the test suite',
'testHasItemReturnsFalseWhenDeferredItemIsExpired' => 'Testing expiration slows down the test suite',
'testDefaultLifeTime' => 'Testing expiration slows down the test suite',
);

protected static $redis;

public function createCachePool($defaultLifetime = 0)
Expand Down
6 changes: 6 additions & 0 deletions src/Symfony/Component/Cache/Tests/Adapter/ApcuAdapterTest.php
Expand Up @@ -15,6 +15,12 @@

class ApcuAdapterTest extends AdapterTestCase
{
protected $skippedTests = array(
'testExpiration' => 'Testing expiration slows down the test suite',
'testHasItemReturnsFalseWhenDeferredItemIsExpired' => 'Testing expiration slows down the test suite',
'testDefaultLifeTime' => 'Testing expiration slows down the test suite',
);

public function createCachePool($defaultLifetime = 0)
{
if (!function_exists('apcu_fetch') || !ini_get('apc.enabled') || ('cli' === PHP_SAPI && !ini_get('apc.enable_cli'))) {
Expand Down
Expand Up @@ -18,6 +18,7 @@

/**
* @author Kévin Dunglas <dunglas@gmail.com>
* @group time-sensitive
*/
class ChainAdapterTest extends AdapterTestCase
{
Expand Down
Expand Up @@ -26,6 +26,6 @@ class DoctrineAdapterTest extends AdapterTestCase

public function createCachePool($defaultLifetime = 0)
{
return new DoctrineAdapter(new ArrayCache(), '', $defaultLifetime);
return new DoctrineAdapter(new ArrayCache($defaultLifetime), '', $defaultLifetime);
}
}
Expand Up @@ -21,6 +21,6 @@ class NamespacedProxyAdapterTest extends ProxyAdapterTest
{
public function createCachePool($defaultLifetime = 0)
{
return new ProxyAdapter(new ArrayAdapter(), 'foo', $defaultLifetime);
return new ProxyAdapter(new ArrayAdapter($defaultLifetime), 'foo', $defaultLifetime);
}
}

0 comments on commit 49a2cb8

Please sign in to comment.