8000 [tests] Use @requires annotation when possible · symfony/symfony@814d961 · GitHub
[go: up one dir, main page]

Skip to content

Commit 814d961

Browse files
[tests] Use @requires annotation when possible
1 parent 864a58f commit 814d961

File tree

7 files changed

+14
-28
lines changed

7 files changed

+14
-28
lines changed

src/Symfony/Component/Console/Tests/Command/CommandTest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -307,13 +307,12 @@ public function getSetCodeBindToClosureTests()
307307
);
308308
}
309309

310-
/** @dataProvider getSetCodeBindToClosureTests */
310+
/**
311+
* @dataProvider getSetCodeBindToClosureTests
312+
* @requires PHP 5.4
313+
*/
311314
public function testSetCodeBindToClosure($previouslyBound, $expected)
312315
{
313-
if (PHP_VERSION_ID < 50400) {
314-
$this->markTestSkipped('Test skipped, for PHP 5.4+ only.');
315-
}
316-
317316
$code = createClosure();
318317
if ($previouslyBound) {
319318
$code = $code->bindTo($this);

src/Symfony/Component/Form/Tests/Util/StringUtilTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,10 @@ public function testTrim()
2424

2525
/**
2626
* @dataProvider spaceProvider
27+
* @requires extension mbstring
2728
*/
2829
public function testTrimUtf8Separators($hex)
2930
{
30-
if (!function_exists('mb_convert_encoding')) {
31-
$this->markTestSkipped('The "mb_convert_encoding" function is not available');
32-
}
33-
3431
// Convert hexadecimal representation into binary
3532
// H: hex string, high nibble first (UCS-2BE)
3633
// *: repeat until end of string

src/Symfony/Component/HttpKernel/Tests/Profiler/MongoDbProfilerStorageTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public function getName()
4141

4242
/**
4343
* @group legacy
44+
* @requires extension mongo
4445
*/
4546
class MongoDbProfilerStorageTest extends AbstractProfilerStorageTest
4647
{
@@ -131,10 +132,6 @@ protected function getStorage()
131132

132133
protected function setUp()
133134
{
134-
if (!extension_loaded('mongo')) {
135-
$this->markTestSkipped('MongoDbProfilerStorageTest requires the mongo PHP extension and a MongoDB server on localhost');
136-
}
137-
138135
$this->storage = new MongoDbProfilerStorage('mongodb://localhost/symfony_tests/profiler_data', '', '', 86400);
139136
$m = new \ReflectionMethod($this->storage, 'getMongo');
140137
$m->setAccessible(true);

src/Symfony/Component/HttpKernel/Tests/Profiler/SqliteProfilerStorageTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
/**
1717
* @group legacy
18+
* @requires extensin pdo_sqlite
1819
*/
1920
class SqliteProfilerStorageTest extends AbstractProfilerStorageTest
2021
{
@@ -23,10 +24,6 @@ class SqliteProfilerStorageTest extends AbstractProfilerStorageTest
2324

2425
protected function setUp()
2526
{
26-
if (!class_exists('SQLite3') && (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers()))) {
27-
$this->markTestSkipped('This test requires SQLite support in your environment');
28-
}
29-
3027
$this->dbFile = tempnam(sys_get_temp_dir(), 'sf2_sqlite_storage');
3128
if (file_exists($this->dbFile)) {
3229
@unlink($this->dbFile);

src/Symfony/Component/Ldap/Tests/LdapClientTest.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,11 @@
1313

1414
use Symfony\Component\Ldap\LdapClient;
1515

16+
/**
17+
* @requires extension ldap
18+
*/
1619
class LdapClientTest extends \PHPUnit_Framework_TestCase
1720
{
18-
protected function setUp()
19-
{
20-
if (!extension_loaded('ldap')) {
21-
$this->markTestSkipped('The ldap extension is not available');
22-
}
23-
}
24-
2521
/**
2622
* @dataProvider provideLdapEscapeValues
2723
*/

src/Symfony/Component/PropertyInfo/Tests/Extractors/ReflectionExtractorTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,10 @@ public function typesProvider()
7575

7676
/**
7777
* @dataProvider php7TypesProvider
78+
* @requires PHP 7.0
7879
*/
7980
public function testExtractPhp7Type($property, array $type = null)
8081
{
81-
if (!method_exists('\ReflectionMethod', 'getReturnType')) {
82-
$this->markTestSkipped('Available only with PHP 7 and superior.');
83-
}
84-
8582
$this->assertEquals($type, $this->extractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\Php7Dummy', $property, array()));
8683
}
8784

src/Symfony/Component/Translation/Tests/Dumper/IcuResFileDumperTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
class IcuResFileDumperTest extends \PHPUnit_Framework_TestCase
1818
{
19+
/**
20+
* @requires extension mbstring
21+
*/
1922
public function testFormatCatalogue()
2023
{
2124
if (!function_exists('mb_convert_encoding')) {

0 commit comments

Comments
 (0)
0