Browse Source

Compatibility with PHPUnit 6.x

tags/2.0.7
Klimov Paul 8 years ago
parent
commit
f0fb0093f6
  1. 2
      .travis.yml
  2. 3
      tests/ActiveFieldTest.php
  3. 4
      tests/CollapseTest.php
  4. 2
      tests/TestCase.php
  5. 2
      tests/bootstrap.php
  6. 32
      tests/compatibility.php

2
.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

3
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]);

4
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;

2
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()
{

2
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');

32
tests/compatibility.php

@ -0,0 +1,32 @@
<?php
/*
* Ensures compatibility with PHPUnit < 6.x
*/
namespace PHPUnit\Framework\Constraint {
if (!class_exists('PHPUnit\Framework\Constraint\Constraint') && class_exists('PHPUnit_Framework_Constraint')) {
abstract class Constraint extends \PHPUnit_Framework_Constraint {}
}
}
namespace PHPUnit\Framework {
if (!class_exists('PHPUnit\Framework\TestCase') && class_exists('PHPUnit_Framework_TestCase')) {
abstract class TestCase extends \PHPUnit_Framework_TestCase {
/**
* @param string $exception
*/
public function expectException($exception)
{
$this->setExpectedException($exception);
}
/**
* @param string $message
*/
public function expectExceptionMessage($message)
{
$this->setExpectedException($this->getExpectedException(), $message);
}
}
}
}
Loading…
Cancel
Save