Skip to content

Commit

Permalink
Merge pull request #2360 from IonBazan/refactor/requires
Browse files Browse the repository at this point in the history
use @requires annotations to skip tests on older PHP versions
  • Loading branch information
malarzm authored Aug 17, 2021
2 parents 9ca6f5f + 30b74bf commit 5ff9dff
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 30 deletions.
15 changes: 3 additions & 12 deletions tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH2310Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,11 @@
use Documents74\GH2310Embedded;
use MongoDB\BSON\ObjectId;

use function phpversion;
use function version_compare;

/**
* @requires PHP 7.4
*/
class GH2310Test extends BaseTest
{
public function setUp(): void
{
if (version_compare((string) phpversion(), '7.4.0', '<')) {
self::markTestSkipped('PHP 7.4 is required to run this test');
}

parent::setUp();
}

public function testFindWithNullableEmbeddedAfterUpsert(): void
{
$document = new GH2310Container((string) new ObjectId(), null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,12 @@
use MongoDB\BSON\ObjectId;

use function assert;
use function phpversion;
use function version_compare;

/**
* @requires PHP 7.4
*/
class TypedPropertiesTest extends BaseTest
{
public function setUp(): void
{
if (version_compare((string) phpversion(), '7.4.0', '<')) {
$this->markTestSkipped('PHP 7.4 is required to run this test');
}

parent::setUp();
}

public function testPersistNew(): void
{
$ref = new TypedDocument();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
use Doctrine\ODM\MongoDB\PersistentCollection\DefaultPersistentCollectionGenerator;
use Doctrine\ODM\MongoDB\Tests\BaseTest;

use function phpversion;
use function version_compare;

/**
* Tests aims to check if classes generated for various PHP versions are correct (i.e. parses).
*/
Expand Down Expand Up @@ -49,12 +46,11 @@ public function testWithNullableReturnType()
$this->assertInstanceOf(CollWithNullableReturnType::class, $coll);
}

/**
* @requires PHP 8.0
*/
public function testPHP80Types()
{
if (version_compare((string) phpversion(), '8.0.0', '<')) {
$this->markTestSkipped('PHP 8.0 is required to run this test');
}

$class = $this->generator->loadClass(CollWithPHP80Types::class, Configuration::AUTOGENERATE_EVAL);
$coll = new $class(new CollWithPHP80Types(), $this->dm, $this->uow);
$this->assertInstanceOf(CollWithPHP80Types::class, $coll);
Expand Down

0 comments on commit 5ff9dff

Please sign in to comment.