Skip to content

Commit

Permalink
Cleaning.
Browse files Browse the repository at this point in the history
  • Loading branch information
mageekguy committed Jul 26, 2012
1 parent 511a62d commit 8ff37c4
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions tests/units/classes/mock/generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

use
mageekguy\atoum,
mageekguy\atoum\mock
mageekguy\atoum\mock,
mageekguy\atoum\mock\generator as testedClass
;

require_once __DIR__ . '/../../runner.php';
Expand All @@ -14,11 +15,11 @@ class generator extends atoum\test
public function test__construct()
{
$this
->if($generator = new mock\generator())
->if($generator = new testedClass())
->then
->object($generator->getFactory())->isInstanceOf('mageekguy\atoum\factory')
->if($factory = new atoum\factory())
->and($generator = new mock\generator($factory))
->and($generator = new testedClass($factory))
->then
->object($generator->getFactory())->isIdenticalTo($factory)
;
Expand All @@ -27,7 +28,7 @@ public function test__construct()
public function testSetDefaultNamespace()
{
$this
->if($generator = new mock\generator())
->if($generator = new testedClass())
->then
->object($generator->setDefaultNamespace($namespace = uniqid()))->isIdenticalTo($generator)
->string($generator->getDefaultNamespace())->isEqualTo('\\' . $namespace)
Expand All @@ -43,7 +44,7 @@ public function testSetDefaultNamespace()
public function testOverload()
{
$this
->if($generator = new mock\generator())
->if($generator = new testedClass())
->then
->object($generator->overload(new mock\php\method($method = uniqid())))->isIdenticalTo($generator)
->boolean($generator->isOverloaded($method))->isTrue()
Expand All @@ -53,7 +54,7 @@ public function testOverload()
public function testIsOverloaded()
{
$this
->if($generator = new mock\generator())
->if($generator = new testedClass())
->then
->boolean($generator->isOverloaded(uniqid()))->isFalse()
->if($generator->overload(new mock\php\method($method = uniqid())))
Expand All @@ -65,7 +66,7 @@ public function testIsOverloaded()
public function testGetOverload()
{
$this
->if($generator = new mock\generator())
->if($generator = new testedClass())
->then
->variable($generator->getOverload(uniqid()))->isNull()
->if($generator->overload($overload = new mock\php\method(uniqid())))
Expand All @@ -77,7 +78,7 @@ public function testGetOverload()
public function testShunt()
{
$this
->if($generator = new mock\generator())
->if($generator = new testedClass())
->then
->object($generator->shunt($method = uniqid()))->isIdenticalTo($generator)
->boolean($generator->isShunted($method))->isTrue()
Expand All @@ -90,7 +91,7 @@ public function testShunt()
public function testOrphanize()
{
$this
->if($generator = new mock\generator())
->if($generator = new testedClass())
->then
->object($generator->orphanize($method = uniqid()))->isIdenticalTo($generator)
->boolean($generator->isOverloaded($method))->isTrue()
Expand All @@ -105,7 +106,7 @@ public function testGetMockedClassCodeForUnknownClass()
->and($adapter->class_exists = false)
->and($factory = new atoum\factory())
->and($factory['mageekguy\atoum\adapter'] = $adapter)
->and($generator = new mock\generator($factory))
->and($generator = new testedClass($factory))
->then
->string($generator->getMockedClassCode($unknownClass = uniqid()))->isEqualTo(
'namespace mock {' . PHP_EOL .
Expand Down Expand Up @@ -207,7 +208,7 @@ public function testGetMockedClassCodeForRealClass()
->and($factory = new atoum\factory())
->and($factory['reflectionClass'] = $reflectionClass)
->and($factory['mageekguy\atoum\adapter'] = $adapter)
->and($generator = new mock\generator($factory))
->and($generator = new testedClass($factory))
->then
->string($generator->getMockedClassCode($realClass = uniqid()))->isEqualTo(
'namespace mock {' . PHP_EOL .
Expand Down Expand Up @@ -296,7 +297,7 @@ public function testGetMockedClassCodeWithOverloadMethod()
->and($factory = new atoum\factory())
->and($factory['reflectionClass'] = $reflectionClass)
->and($factory['mageekguy\atoum\adapter'] = $adapter)
->and($generator = new mock\generator($factory))
->and($generator = new testedClass($factory))
->and($generator->overload($overloadedMethod))
->then
->string($generator->getMockedClassCode($realClass = uniqid()))->isEqualTo(
Expand Down Expand Up @@ -385,7 +386,7 @@ public function testGetMockedClassCodeWithAbstractMethod()
->and($factory = new atoum\factory())
->and($factory['reflectionClass'] = $reflectionClass)
->and($factory['mageekguy\atoum\adapter'] = $adapter)
->and($generator = new mock\generator($factory))
->and($generator = new testedClass($factory))
->then
->string($generator->getMockedClassCode($realClass))->isEqualTo(
'namespace mock {' . PHP_EOL .
Expand Down Expand Up @@ -468,7 +469,7 @@ public function testGetMockedClassCodeWithShuntedMethod()
->and($factory = new atoum\factory())
->and($factory['reflectionClass'] = $reflectionClass)
->and($factory['mageekguy\atoum\adapter'] = $adapter)
->and($generator = new mock\generator($factory))
->and($generator = new testedClass($factory))
->and($generator->shunt('__construct'))
->then
->string($generator->getMockedClassCode($realClass))->isEqualTo(
Expand Down Expand Up @@ -548,7 +549,7 @@ public function testGetMockedClassCodeForInterface()
->and($factory = new atoum\factory())
->and($factory['reflectionClass'] = $reflectionClass)
->and($factory['mageekguy\atoum\adapter'] = $adapter)
->and($generator = new mock\generator($factory))
->and($generator = new testedClass($factory))
->then
->string($generator->getMockedClassCode($realClass = uniqid()))->isEqualTo(
'namespace mock {' . PHP_EOL .
Expand Down Expand Up @@ -630,7 +631,7 @@ public function testGetMockedClassCodeForRealClassWithoutConstructor()
->and($factory = new atoum\factory())
->and($factory['reflectionClass'] = $reflectionClass)
->and($factory['mageekguy\atoum\adapter'] = $adapter)
->and($generator = new mock\generator($factory))
->and($generator = new testedClass($factory))
->then
->string($generator->getMockedClassCode($realClass = uniqid()))->isEqualTo(
'namespace mock {' . PHP_EOL .
Expand Down Expand Up @@ -736,7 +737,7 @@ public function testGetMockedClassCodeWithProtectedAbstractMethod()
->and($factory = new atoum\factory())
->and($factory['reflectionClass'] = $class)
->and($factory['mageekguy\atoum\adapter'] = $adapter)
->and($generator = new mock\generator($factory))
->and($generator = new testedClass($factory))
->then
->string($generator->getMockedClassCode($className))->isEqualTo(
'namespace mock {' . PHP_EOL .
Expand Down Expand Up @@ -828,7 +829,7 @@ public function testGetMockedClassCodeForAbstractClassWithConstructorInInterface
->and($factory = new atoum\factory())
->and($factory['reflectionClass'] = $class)
->and($factory['mageekguy\atoum\adapter'] = $adapter)
->and($generator = new mock\generator($factory))
->and($generator = new testedClass($factory))
->then
->string($generator->getMockedClassCode($className))->isEqualTo(
'namespace mock {' . PHP_EOL .
Expand Down Expand Up @@ -887,7 +888,7 @@ public function testGetMockedClassCodeForAbstractClassWithConstructorInInterface
public function testGenerate()
{
$this
->if($generator = new mock\generator())
->if($generator = new testedClass())
->then
->exception(function() use ($generator) { $generator->generate(''); })
->isInstanceOf('mageekguy\atoum\exceptions\runtime')
Expand All @@ -901,7 +902,7 @@ public function testGenerate()
->if($adapter = new atoum\test\adapter())
->and($factory = new atoum\factory())
->and($factory['mageekguy\atoum\adapter'] = $adapter)
->and($generator = new mock\generator($factory))
->and($generator = new testedClass($factory))
->and($adapter->class_exists = false)
->and($adapter->interface_exists = false)
->and($class = uniqid('unknownClass'))
Expand Down Expand Up @@ -958,13 +959,13 @@ public function testGenerate()
->isInstanceOf('mageekguy\atoum\exceptions\logic')
->hasMessage('Class \'' . $class . '\' is final, unable to mock it')
->if($reflectionClassController->isFinal = false)
->and($generator = new mock\generator())
->and($generator = new testedClass())
->then
->object($generator->generate(__CLASS__))->isIdenticalTo($generator)
->class('\mock\\' . __CLASS__)
->hasParent(__CLASS__)
->hasInterface('mageekguy\atoum\mock\aggregator')
->if($generator = new mock\generator())
->if($generator = new testedClass())
->and($generator->shunt('__construct'))
->then
->boolean($generator->isShunted('__construct'))->isTrue()
Expand Down

0 comments on commit 8ff37c4

Please sign in to comment.