Ejemplo n.º 1
0
 public function testSubsequentInheritance()
 {
     $mocka = new Mocka();
     $mockClass = $mocka->mockClass('\\Mocka\\Mocka');
     $mockClass->mockMethod('foo')->set(function () {
         return 'foo';
     });
     $mockClassChild = $mocka->mockClass($mockClass->getClassName());
     $this->assertInstanceOf($mockClass->getClassName(), $mockClassChild->newInstanceWithoutConstructor());
     $this->assertInstanceOf('\\Mocka\\Mocka', $mockClassChild->newInstanceWithoutConstructor());
 }
Ejemplo n.º 2
0
 public function testCallMockedMethod()
 {
     $mocka = new Mocka();
     $mockClass = $mocka->mockClass('\\MockaMocks\\AbstractClass');
     /** @var \MockaMocks\AbstractClass|\Mocka\AbstractClassTrait $object */
     $object = $mockClass->newInstanceWithoutConstructor();
     $this->assertNull($object->foo());
     $this->assertSame('bar', $object->bar());
     $mockClass->mockMethod('foo')->set(function () {
         return 'foo';
     });
     $this->assertSame('foo', $object->foo());
     $object->mockMethod('foo')->set(function () {
         return 'bar';
     });
     $this->assertSame('bar', $object->foo());
     $objectAnother = $mockClass->newInstanceWithoutConstructor();
     $this->assertSame('foo', $objectAnother->foo());
     $mockClass->mockMethod('foo')->set(function () {
         return 'zoo';
     });
     $this->assertSame('bar', $object->foo());
 }