2 class Framework_MockObject_GeneratorTest
extends PHPUnit_Framework_TestCase
5 * @covers PHPUnit_Framework_MockObject_Generator::getMock
6 * @expectedException PHPUnit_Framework_Exception
8 public function testGetMockFailsWhenInvalidFunctionNameIsPassedInAsAFunctionToMock()
10 PHPUnit_Framework_MockObject_Generator
::getMock('StdClass', array(0));
14 * @covers PHPUnit_Framework_MockObject_Generator::getMock
16 public function testGetMockCanCreateNonExistingFunctions()
18 $mock = PHPUnit_Framework_MockObject_Generator
::getMock('StdClass', array('testFunction'));
19 $this->assertTrue(method_exists($mock, 'testFunction'));
23 * @covers PHPUnit_Framework_MockObject_Generator::getMock
24 * @expectedException PHPUnit_Framework_Exception
25 * @expectedExceptionMessage duplicates: "foo, foo"
27 public function testGetMockGeneratorFails()
29 $mock = PHPUnit_Framework_MockObject_Generator
::getMock('StdClass', array('foo', 'foo'));
33 * @covers PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass
35 public function testGetMockForAbstractClassDoesNotFailWhenFakingInterfaces()
37 $mock = PHPUnit_Framework_MockObject_Generator
::getMockForAbstractClass('Countable');
38 $this->assertTrue(method_exists($mock, 'count'));
42 * @covers PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass
44 public function testGetMockForAbstractClassStubbingAbstractClass()
46 $mock = PHPUnit_Framework_MockObject_Generator
::getMockForAbstractClass('AbstractMockTestClass');
47 $this->assertTrue(method_exists($mock, 'doSomething'));
51 * @dataProvider getMockForAbstractClassExpectsInvalidArgumentExceptionDataprovider
52 * @covers PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass
53 * @expectedException PHPUnit_Framework_Exception
55 public function testGetMockForAbstractClassExpectingInvalidArgumentException($className, $mockClassName)
57 $mock = PHPUnit_Framework_MockObject_Generator
::getMockForAbstractClass($className, array(), $mockClassName);
61 * @covers PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass
62 * @expectedException PHPUnit_Framework_Exception
64 public function testGetMockForAbstractClassAnstractClassDoesNotExist()
66 $mock = PHPUnit_Framework_MockObject_Generator
::getMockForAbstractClass('Tux');
70 * Dataprovider for test "testGetMockForAbstractClassExpectingInvalidArgumentException"
72 public static function getMockForAbstractClassExpectsInvalidArgumentExceptionDataprovider()
75 'className not a string' => array(array(), ''),
76 'mockClassName not a string' => array('Countable', new StdClass
),