From f0fb0093f6e5d08ab05c35225bb0c0cfc57dd34d Mon Sep 17 00:00:00 2001 From: Klimov Paul Date: Thu, 13 Apr 2017 13:53:05 +0300 Subject: [PATCH] Compatibility with PHPUnit 6.x --- .travis.yml | 2 +- tests/ActiveFieldTest.php | 3 ++- tests/CollapseTest.php | 4 +++- tests/TestCase.php | 2 +- tests/bootstrap.php | 2 ++ tests/compatibility.php | 32 ++++++++++++++++++++++++++++++++ 6 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 tests/compatibility.php diff --git a/.travis.yml b/.travis.yml index f4123cf..577336c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,7 @@ cache: install: - travis_retry composer self-update && composer --version - - travis_retry composer global require "fxp/composer-asset-plugin:~1.1.1" + - travis_retry composer global require "fxp/composer-asset-plugin:^1.2.0" - export PATH="$HOME/.composer/vendor/bin:$PATH" - travis_retry composer install --prefer-dist --no-interaction diff --git a/tests/ActiveFieldTest.php b/tests/ActiveFieldTest.php index 76aa6ef..93c5217 100644 --- a/tests/ActiveFieldTest.php +++ b/tests/ActiveFieldTest.php @@ -36,7 +36,8 @@ class ActiveFieldTest extends TestCase $this->helperModel = new DynamicModel(['attributeName']); ob_start(); - $this->helperForm = new ActiveForm(['action' => '/something']); + $this->helperForm = ActiveForm::begin(['action' => '/something', 'enableClientScript' => false]); + ActiveForm::end(); ob_end_clean(); $this->activeField = new ActiveField(['form' => $this->helperForm]); diff --git a/tests/CollapseTest.php b/tests/CollapseTest.php index aa703bc..5717e2a 100644 --- a/tests/CollapseTest.php +++ b/tests/CollapseTest.php @@ -2,6 +2,7 @@ namespace yiiunit\extensions\bootstrap; use yii\bootstrap\Collapse; +use yii\widgets\ActiveForm; /** * @group bootstrap @@ -116,7 +117,8 @@ HTML { $template = ['template' => '{input}']; ob_start(); - $form = \yii\widgets\ActiveForm::begin(['action' => '/something']); + $form = ActiveForm::begin(['action' => '/something']); + ActiveForm::end(); ob_end_clean(); $model = new data\Singer; diff --git a/tests/TestCase.php b/tests/TestCase.php index 95cf330..912f484 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -9,7 +9,7 @@ use Yii; /** * This is the base class for all yii framework unit tests. */ -abstract class TestCase extends \PHPUnit_Framework_TestCase +abstract class TestCase extends \PHPUnit\Framework\TestCase { protected function setUp() { diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 0eb9a9b..a0c888d 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -13,3 +13,5 @@ require_once(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php'); Yii::setAlias('@yiiunit/extensions/bootstrap', __DIR__); Yii::setAlias('@yii/bootstrap', dirname(__DIR__)); + +require_once(__DIR__ . '/compatibility.php'); \ No newline at end of file diff --git a/tests/compatibility.php b/tests/compatibility.php new file mode 100644 index 0000000..f7fd3f2 --- /dev/null +++ b/tests/compatibility.php @@ -0,0 +1,32 @@ +setExpectedException($exception); + } + + /** + * @param string $message + */ + public function expectExceptionMessage($message) + { + $this->setExpectedException($this->getExpectedException(), $message); + } + } + } +}