Skip to content

Commit

Permalink
Added test for magic methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Revah committed Mar 14, 2015
1 parent 472953d commit 6ce59fa
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/ShortifyPunitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,22 @@ final class FinalClassForMocking

interface InterfaceTest
{
}

/**
* Class MagicClass
*/
class MagicClass
{
public function __call($method, $arguments)
{
return '__call';
}

public function __toString()
{
return '__toString';
}
}

class ShortifyPunitTest extends \PHPUnit_Framework_TestCase
Expand Down Expand Up @@ -402,4 +417,17 @@ public function testHamcrestWithNormalParam()
$this->assertEquals($mock->first_method('anything...', 'a'), 1);
$this->assertEquals($mock->first_method('anything...', 'b'), 2);
}

/**
* Stubbing magic methods
*/
public function testStubbingMagicMethods()
{
$mock = ShortifyPunit::mock('MagicClass');

ShortifyPunit::when($mock)->__toString()->returns('mockString');

$this->assertEquals($mock->__toString(), 'mockString');
$this->assertEquals($mock, 'mockString');
}
}

0 comments on commit 6ce59fa

Please sign in to comment.