Skip to content

Commit

Permalink
Replace usages of SkippedTestSuiteError with markTestSkipped() call
Browse files Browse the repository at this point in the history
  • Loading branch information
digilist authored and nicolas-grekas committed Sep 28, 2023
1 parent 1d57d1a commit b0878f1
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 21 deletions.
5 changes: 2 additions & 3 deletions Tests/Store/MemcachedStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace Symfony\Component\Lock\Tests\Store;

use PHPUnit\Framework\SkippedTestSuiteError;
use Symfony\Component\Lock\Exception\InvalidTtlException;
use Symfony\Component\Lock\Key;
use Symfony\Component\Lock\PersistingStoreInterface;
Expand All @@ -31,7 +30,7 @@ class MemcachedStoreTest extends AbstractStoreTestCase
public static function setUpBeforeClass(): void
{
if (version_compare(phpversion('memcached'), '3.1.6', '<')) {
throw new SkippedTestSuiteError('Extension memcached > 3.1.5 required.');
self::markTestSkipped('Extension memcached > 3.1.5 required.');
}

$memcached = new \Memcached();
Expand All @@ -40,7 +39,7 @@ public static function setUpBeforeClass(): void
$code = $memcached->getResultCode();

if (\Memcached::RES_SUCCESS !== $code && \Memcached::RES_NOTFOUND !== $code) {
throw new SkippedTestSuiteError('Unable to connect to the memcache host');
self::markTestSkipped('Unable to connect to the memcache host');
}
}

Expand Down
5 changes: 2 additions & 3 deletions Tests/Store/MongoDbStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use MongoDB\Client;
use MongoDB\Driver\Exception\ConnectionTimeoutException;
use PHPUnit\Framework\SkippedTestSuiteError;
use Symfony\Component\Lock\Exception\InvalidArgumentException;
use Symfony\Component\Lock\Key;
use Symfony\Component\Lock\PersistingStoreInterface;
Expand All @@ -33,14 +32,14 @@ class MongoDbStoreTest extends AbstractStoreTestCase
public static function setupBeforeClass(): void
{
if (!class_exists(\MongoDB\Client::class)) {
throw new SkippedTestSuiteError('The mongodb/mongodb package is required.');
self::markTestSkipped('The mongodb/mongodb package is required.');
}

$client = self::getMongoClient();
try {
$client->listDatabases();
} catch (ConnectionTimeoutException $e) {
throw new SkippedTestSuiteError('MongoDB server not found.');
self::markTestSkipped('MongoDB server not found.');
}
}

Expand Down
4 changes: 1 addition & 3 deletions Tests/Store/PredisStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

namespace Symfony\Component\Lock\Tests\Store;

use PHPUnit\Framework\SkippedTestSuiteError;

/**
* @author Jérémy Derussé <jeremy@derusse.com>
*
Expand All @@ -26,7 +24,7 @@ public static function setUpBeforeClass(): void
try {
$redis->connect();
} catch (\Exception $e) {
throw new SkippedTestSuiteError($e->getMessage());
self::markTestSkipped($e->getMessage());
}
}

Expand Down
6 changes: 2 additions & 4 deletions Tests/Store/RedisArrayStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

namespace Symfony\Component\Lock\Tests\Store;

use PHPUnit\Framework\SkippedTestSuiteError;

/**
* @author Jérémy Derussé <jeremy@derusse.com>
*
Expand All @@ -25,12 +23,12 @@ class RedisArrayStoreTest extends AbstractRedisStoreTestCase
public static function setUpBeforeClass(): void
{
if (!class_exists(\RedisArray::class)) {
throw new SkippedTestSuiteError('The RedisArray class is required.');
self::markTestSkipped('The RedisArray class is required.');
}
try {
(new \Redis())->connect(...explode(':', getenv('REDIS_HOST')));
} catch (\Exception $e) {
throw new SkippedTestSuiteError($e->getMessage());
self::markTestSkipped($e->getMessage());
}
}

Expand Down
6 changes: 2 additions & 4 deletions Tests/Store/RedisClusterStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

namespace Symfony\Component\Lock\Tests\Store;

use PHPUnit\Framework\SkippedTestSuiteError;

/**
* @author Jérémy Derussé <jeremy@derusse.com>
*
Expand All @@ -25,10 +23,10 @@ class RedisClusterStoreTest extends AbstractRedisStoreTestCase
public static function setUpBeforeClass(): void
{
if (!class_exists(\RedisCluster::class)) {
throw new SkippedTestSuiteError('The RedisCluster class is required.');
self::markTestSkipped('The RedisCluster class is required.');
}
if (!getenv('REDIS_CLUSTER_HOSTS')) {
throw new SkippedTestSuiteError('REDIS_CLUSTER_HOSTS env var is not defined.');
self::markTestSkipped('REDIS_CLUSTER_HOSTS env var is not defined.');
}
}

Expand Down
3 changes: 1 addition & 2 deletions Tests/Store/RedisStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace Symfony\Component\Lock\Tests\Store;

use PHPUnit\Framework\SkippedTestSuiteError;
use Symfony\Component\Lock\Exception\InvalidTtlException;
use Symfony\Component\Lock\Store\RedisStore;

Expand All @@ -31,7 +30,7 @@ public static function setUpBeforeClass(): void
try {
(new \Redis())->connect(...explode(':', getenv('REDIS_HOST')));
} catch (\Exception $e) {
throw new SkippedTestSuiteError($e->getMessage());
self::markTestSkipped($e->getMessage());
}
}

Expand Down
3 changes: 1 addition & 2 deletions Tests/Store/RelayStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace Store;

use PHPUnit\Framework\SkippedTestSuiteError;
use Relay\Relay;
use Symfony\Component\Lock\Tests\Store\AbstractRedisStoreTestCase;
use Symfony\Component\Lock\Tests\Store\SharedLockStoreTestTrait;
Expand All @@ -30,7 +29,7 @@ public static function setUpBeforeClass(): void
try {
new Relay(...explode(':', getenv('REDIS_HOST')));
} catch (\Relay\Exception $e) {
throw new SkippedTestSuiteError($e->getMessage());
self::markTestSkipped($e->getMessage());
}
}

Expand Down

0 comments on commit b0878f1

Please sign in to comment.