Skip to content

Commit

Permalink
removed some duplicate code in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
craue committed Jun 23, 2015
1 parent 2e2c900 commit 326817f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
14 changes: 7 additions & 7 deletions Tests/Form/FormFlowBcMethodsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class FormFlowBcMethodsTest extends UnitTestCase {
private $deprecatedMessage = 'Method Craue\FormFlowBundle\Form\FormFlow::%s is deprecated since version 2.0. Use method %s instead.';

public function testBcMethodDelegation_getCurrentStep() {
$flow = $this->getMock('\Craue\FormFlowBundle\Form\FormFlow', array('getName', 'getCurrentStepNumber'));
$flow = $this->getFlowWithMockedMethods(array('getName', 'getCurrentStepNumber'));

$flow
->expects($this->once())
Expand All @@ -33,7 +33,7 @@ public function testBcMethodDelegation_getCurrentStep() {
}

public function testBcMethodDelegation_getCurrentStepDescription() {
$flow = $this->getMock('\Craue\FormFlowBundle\Form\FormFlow', array('getName', 'getCurrentStepLabel'));
$flow = $this->getFlowWithMockedMethods(array('getName', 'getCurrentStepLabel'));

$flow
->expects($this->once())
Expand All @@ -46,7 +46,7 @@ public function testBcMethodDelegation_getCurrentStepDescription() {
}

public function testBcMethodDelegation_getMaxSteps() {
$flow = $this->getMock('\Craue\FormFlowBundle\Form\FormFlow', array('getName', 'getStepCount'));
$flow = $this->getFlowWithMockedMethods(array('getName', 'getStepCount'));

$flow
->expects($this->once())
Expand All @@ -59,7 +59,7 @@ public function testBcMethodDelegation_getMaxSteps() {
}

public function testBcMethodDelegation_getStepDescriptions() {
$flow = $this->getMock('\Craue\FormFlowBundle\Form\FormFlow', array('getName', 'getStepLabels'));
$flow = $this->getFlowWithMockedMethods(array('getName', 'getStepLabels'));

$flow
->expects($this->once())
Expand All @@ -72,7 +72,7 @@ public function testBcMethodDelegation_getStepDescriptions() {
}

public function testBcMethodDelegation_getFirstStep() {
$flow = $this->getMock('\Craue\FormFlowBundle\Form\FormFlow', array('getName', 'getFirstStepNumber'));
$flow = $this->getFlowWithMockedMethods(array('getName', 'getFirstStepNumber'));

$flow
->expects($this->once())
Expand All @@ -85,7 +85,7 @@ public function testBcMethodDelegation_getFirstStep() {
}

public function testBcMethodDelegation_getLastStep() {
$flow = $this->getMock('\Craue\FormFlowBundle\Form\FormFlow', array('getName', 'getLastStepNumber'));
$flow = $this->getFlowWithMockedMethods(array('getName', 'getLastStepNumber'));

$flow
->expects($this->once())
Expand All @@ -98,7 +98,7 @@ public function testBcMethodDelegation_getLastStep() {
}

public function testBcMethodDelegation_hasSkipStep() {
$flow = $this->getMock('\Craue\FormFlowBundle\Form\FormFlow', array('getName', 'isStepSkipped'));
$flow = $this->getFlowWithMockedMethods(array('getName', 'isStepSkipped'));

$flow
->expects($this->once())
Expand Down
12 changes: 2 additions & 10 deletions Tests/Util/FormFlowUtilTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Craue\FormFlowBundle\Tests\Util;

use Craue\FormFlowBundle\Form\FormFlow;
use Craue\FormFlowBundle\Tests\UnitTestCase;
use Craue\FormFlowBundle\Util\FormFlowUtil;

/**
Expand All @@ -12,7 +12,7 @@
* @copyright 2011-2015 Christian Raue
* @license http://opensource.org/licenses/mit-license.php MIT License
*/
class FormFlowUtilTest extends \PHPUnit_Framework_TestCase {
class FormFlowUtilTest extends UnitTestCase {

/**
* @var FormFlowUtil
Expand Down Expand Up @@ -67,12 +67,4 @@ public function testRemoveRouteParameters() {
$this->assertEquals(array('key' => 'value'), $actualParameters);
}

/**
* @param string[] $methodNames Names of methods to be mocked.
* @return PHPUnit_Framework_MockObject_MockObject|FormFlow
*/
protected function getFlowWithMockedMethods(array $methodNames) {
return $this->getMock('\Craue\FormFlowBundle\Form\FormFlow', $methodNames);
}

}

0 comments on commit 326817f

Please sign in to comment.