<?php
namespace EngineWorks\DBAL\Tests;

use EngineWorks\DBAL\DBAL;
use PHPUnit\Framework\Error\Notice;
use PHPUnit\Runner\Version;

/* @var $this \EngineWorks\DBAL\Tests\TestCaseWithDatabase */

trait TransactionsWithExceptionsTestTrait
{
    /** @return DBAL */
    abstract protected function getDbal();

    private function checkPhpUnitVersion($minimalVersion)
    {
        $phpUnitVersion = '5.6';
        if (class_exists(Version::class)) {
            $phpUnitVersion = Version::series();
        }
        if (version_compare($phpUnitVersion, $minimalVersion, '<')) {
            $this->markTestSkipped(sprintf('This test only runs on phpunit %s or higher', $minimalVersion));
        }
    }

    public function testCommitThrowsWarningWithOutBegin()
    {
        $this->checkPhpUnitVersion('6.0');
        $this->expectException(Notice::class);
        $this->getDbal()->transCommit();
    }

    public function testRollbackThrowsWarningWithOutBegin()
    {
        $this->checkPhpUnitVersion('6.0');
        $this->expectException(Notice::class);
        $this->getDbal()->transRollback();
    }
}

<?php
namespace EngineWorks\DBAL\Tests;

use EngineWorks\DBAL\DBAL;
use PHPUnit\Framework\Error\Notice;

/* @var $this \EngineWorks\DBAL\Tests\TestCaseWithDatabase */

trait TransactionsWithExceptionsTestTrait
{
    /** @return DBAL */
    abstract protected function getDbal();

    public function testCommitThrowsWarningWithOutBegin()
    {
        if (version_compare(PHP_VERSION, '7.0', '<')) {
            $this->markTestSkipped('This test only runs on php 7.0 or higher');
        }
        $this->expectException(Notice::class);
        $this->getDbal()->transCommit();
    }

    public function testRollbackThrowsWarningWithOutBegin()
    {
        if (version_compare(PHP_VERSION, '7.0', '<')) {
            $this->markTestSkipped('This test only runs on php 7.0 or higher');
        }
        $this->expectException(Notice::class);
        $this->getDbal()->transRollback();
    }
}

--- 
+++ 
@@ -3,6 +3,7 @@
 
 use EngineWorks\DBAL\DBAL;
 use PHPUnit\Framework\Error\Notice;
+use PHPUnit\Runner\Version;
 
 /* @var $this \EngineWorks\DBAL\Tests\TestCaseWithDatabase */
 
@@ -11,20 +12,27 @@
     /** @return DBAL */
     abstract protected function getDbal();
 
+    private function checkPhpUnitVersion($minimalVersion)
+    {
+        $phpUnitVersion = '5.6';
+        if (class_exists(Version::class)) {
+            $phpUnitVersion = Version::series();
+        }
+        if (version_compare($phpUnitVersion, $minimalVersion, '<')) {
+            $this->markTestSkipped(sprintf('This test only runs on phpunit %s or higher', $minimalVersion));
+        }
+    }
+
     public function testCommitThrowsWarningWithOutBegin()
     {
-        if (version_compare(PHP_VERSION, '7.0', '<')) {
-            $this->markTestSkipped('This test only runs on php 7.0 or higher');
-        }
+        $this->checkPhpUnitVersion('6.0');
         $this->expectException(Notice::class);
         $this->getDbal()->transCommit();
     }
 
     public function testRollbackThrowsWarningWithOutBegin()
     {
-        if (version_compare(PHP_VERSION, '7.0', '<')) {
-            $this->markTestSkipped('This test only runs on php 7.0 or higher');
-        }
+        $this->checkPhpUnitVersion('6.0');
         $this->expectException(Notice::class);
         $this->getDbal()->transRollback();
     }
Test against phpunit version, not php version
