add myCalendar into
[awl.git] / vendor / phpunit / phpunit-mock-objects / Tests / GeneratorTest.php
blob2ffbbc3125246aa363799d56651fd2c58ab278af
1 <?php
2 class Framework_MockObject_GeneratorTest extends PHPUnit_Framework_TestCase
4 /**
5 * @covers PHPUnit_Framework_MockObject_Generator::getMock
6 * @expectedException PHPUnit_Framework_Exception
7 */
8 public function testGetMockFailsWhenInvalidFunctionNameIsPassedInAsAFunctionToMock()
10 PHPUnit_Framework_MockObject_Generator::getMock('StdClass', array(0));
13 /**
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'));
22 /**
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'));
32 /**
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'));
41 /**
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'));
50 /**
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);
60 /**
61 * @covers PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass
62 * @expectedException PHPUnit_Framework_Exception
64 public function testGetMockForAbstractClassAnstractClassDoesNotExist()
66 $mock = PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass('Tux');
69 /**
70 * Dataprovider for test "testGetMockForAbstractClassExpectingInvalidArgumentException"
72 public static function getMockForAbstractClassExpectsInvalidArgumentExceptionDataprovider()
74 return array(
75 'className not a string' => array(array(), ''),
76 'mockClassName not a string' => array('Countable', new StdClass),