Skip to content

Commit

Permalink
improved collecting deprecation notices during tests by using PHPUnit…
Browse files Browse the repository at this point in the history
…Bridge's new `@expectedDeprecation` annotation
  • Loading branch information
craue committed Nov 30, 2016
1 parent 52fd639 commit f33cc30
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 78 deletions.
36 changes: 23 additions & 13 deletions Tests/Form/FormFlowBcMethodsTest.php
Expand Up @@ -2,22 +2,21 @@

namespace Craue\FormFlowBundle\Tests\Form;

use Craue\FormFlowBundle\Tests\UnitTestCase;

/**
* Tests for BC.
*
* @collectDeprecationNotices
* @group legacy
* @group unit
*
* @author Christian Raue <christian.raue@gmail.com>
* @copyright 2011-2016 Christian Raue
* @license http://opensource.org/licenses/mit-license.php MIT License
*/
class FormFlowBcMethodsTest extends UnitTestCase {

private $deprecatedMessage = 'Method Craue\FormFlowBundle\Form\FormFlow::%s is deprecated since version 2.0. Use method %s instead.';
class FormFlowBcMethodsTest extends \PHPUnit_Framework_TestCase {

/**
* @expectedDeprecation Method Craue\FormFlowBundle\Form\FormFlow::getCurrentStep is deprecated since version 2.0. Use method getCurrentStepNumber instead.
*/
public function testBcMethodDelegation_getCurrentStep() {
$flowStub = $this->getMockBuilder('\Craue\FormFlowBundle\Form\FormFlow')->setMethods(array('getName', 'getCurrentStepNumber'))->getMock();

Expand All @@ -27,9 +26,11 @@ public function testBcMethodDelegation_getCurrentStep() {
;

$flowStub->getCurrentStep();
$this->assertEquals(array(sprintf($this->deprecatedMessage, 'getCurrentStep', 'getCurrentStepNumber')), $this->getDeprecationNotices());
}

/**
* @expectedDeprecation Method Craue\FormFlowBundle\Form\FormFlow::getCurrentStepDescription is deprecated since version 2.0. Use method getCurrentStepLabel instead.
*/
public function testBcMethodDelegation_getCurrentStepDescription() {
$flowStub = $this->getMockBuilder('\Craue\FormFlowBundle\Form\FormFlow')->setMethods(array('getName', 'getCurrentStepLabel'))->getMock();

Expand All @@ -39,9 +40,11 @@ public function testBcMethodDelegation_getCurrentStepDescription() {
;

$flowStub->getCurrentStepDescription();
$this->assertEquals(array(sprintf($this->deprecatedMessage, 'getCurrentStepDescription', 'getCurrentStepLabel')), $this->getDeprecationNotices());
}

/**
* @expectedDeprecation Method Craue\FormFlowBundle\Form\FormFlow::getMaxSteps is deprecated since version 2.0. Use method getStepCount instead.
*/
public function testBcMethodDelegation_getMaxSteps() {
$flowStub = $this->getMockBuilder('\Craue\FormFlowBundle\Form\FormFlow')->setMethods(array('getName', 'getStepCount'))->getMock();

Expand All @@ -51,9 +54,11 @@ public function testBcMethodDelegation_getMaxSteps() {
;

$flowStub->getMaxSteps();
$this->assertEquals(array(sprintf($this->deprecatedMessage, 'getMaxSteps', 'getStepCount')), $this->getDeprecationNotices());
}

/**
* @expectedDeprecation Method Craue\FormFlowBundle\Form\FormFlow::getStepDescriptions is deprecated since version 2.0. Use method getStepLabels instead.
*/
public function testBcMethodDelegation_getStepDescriptions() {
$flowStub = $this->getMockBuilder('\Craue\FormFlowBundle\Form\FormFlow')->setMethods(array('getName', 'getStepLabels'))->getMock();

Expand All @@ -63,9 +68,11 @@ public function testBcMethodDelegation_getStepDescriptions() {
;

$flowStub->getStepDescriptions();
$this->assertEquals(array(sprintf($this->deprecatedMessage, 'getStepDescriptions', 'getStepLabels')), $this->getDeprecationNotices());
}

/**
* @expectedDeprecation Method Craue\FormFlowBundle\Form\FormFlow::getFirstStep is deprecated since version 2.0. Use method getFirstStepNumber instead.
*/
public function testBcMethodDelegation_getFirstStep() {
$flowStub = $this->getMockBuilder('\Craue\FormFlowBundle\Form\FormFlow')->setMethods(array('getName', 'getFirstStepNumber'))->getMock();

Expand All @@ -75,9 +82,11 @@ public function testBcMethodDelegation_getFirstStep() {
;

$flowStub->getFirstStep();
$this->assertEquals(array(sprintf($this->deprecatedMessage, 'getFirstStep', 'getFirstStepNumber')), $this->getDeprecationNotices());
}

/**
* @expectedDeprecation Method Craue\FormFlowBundle\Form\FormFlow::getLastStep is deprecated since version 2.0. Use method getLastStepNumber instead.
*/
public function testBcMethodDelegation_getLastStep() {
$flowStub = $this->getMockBuilder('\Craue\FormFlowBundle\Form\FormFlow')->setMethods(array('getName', 'getLastStepNumber'))->getMock();

Expand All @@ -87,9 +96,11 @@ public function testBcMethodDelegation_getLastStep() {
;

$flowStub->getLastStep();
$this->assertEquals(array(sprintf($this->deprecatedMessage, 'getLastStep', 'getLastStepNumber')), $this->getDeprecationNotices());
}

/**
* @expectedDeprecation Method Craue\FormFlowBundle\Form\FormFlow::hasSkipStep is deprecated since version 2.0. Use method isStepSkipped instead.
*/
public function testBcMethodDelegation_hasSkipStep() {
$flowStub = $this->getMockBuilder('\Craue\FormFlowBundle\Form\FormFlow')->setMethods(array('getName', 'isStepSkipped'))->getMock();

Expand All @@ -102,7 +113,6 @@ public function testBcMethodDelegation_hasSkipStep() {
;

$flowStub->hasSkipStep($stepNumber);
$this->assertEquals(array(sprintf($this->deprecatedMessage, 'hasSkipStep', 'isStepSkipped')), $this->getDeprecationNotices());
}

}
64 changes: 0 additions & 64 deletions Tests/UnitTestCase.php

This file was deleted.

2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -24,7 +24,7 @@
"doctrine/common": "~2.3",
"phpunit/phpunit": "~4.1|~5.0",
"sensio/framework-extra-bundle": "~2.1|~3.0",
"symfony/phpunit-bridge": "^2.8.1",
"symfony/phpunit-bridge": "~3.2",
"symfony/symfony": "^2.1.3"
},
"minimum-stability": "stable",
Expand Down
3 changes: 3 additions & 0 deletions phpunit.xml.dist
Expand Up @@ -25,4 +25,7 @@
<env name="LOG_DIR" value="/path/to/your/log/" />
</php>
-->
<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
</listeners>
</phpunit>

0 comments on commit f33cc30

Please sign in to comment.