~ballot/wordpress/openstack-objectstorage-breaking-insight

« back to all changes in this revision

Viewing changes to vendor/phpunit/phpunit-mock-objects/tests/MockObject/class_implementing_interface_call_parent_constructor.phpt

  • Committer: Jacek Nykis
  • Date: 2015-02-11 15:35:31 UTC
  • Revision ID: jacek.nykis@canonical.com-20150211153531-hmy6zi0ov2qfkl0b
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--TEST--
 
2
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE)
 
3
--FILE--
 
4
<?php
 
5
interface IFoo
 
6
{
 
7
    public function __construct($bar);
 
8
}
 
9
 
 
10
class Foo implements IFoo
 
11
{
 
12
    public function __construct($bar)
 
13
    {
 
14
    }
 
15
}
 
16
 
 
17
require __DIR__ . '/../../vendor/autoload.php';
 
18
 
 
19
$generator = new PHPUnit_Framework_MockObject_Generator;
 
20
 
 
21
$mock = $generator->generate(
 
22
  'Foo',
 
23
  array(),
 
24
  'MockFoo',
 
25
  TRUE
 
26
);
 
27
 
 
28
print $mock['code'];
 
29
?>
 
30
--EXPECTF--
 
31
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
 
32
{
 
33
    private $__phpunit_invocationMocker;
 
34
    private $__phpunit_originalObject;
 
35
 
 
36
    public function __clone()
 
37
    {
 
38
        $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
 
39
    }
 
40
 
 
41
    public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
 
42
    {
 
43
        return $this->__phpunit_getInvocationMocker()->expects($matcher);
 
44
    }
 
45
 
 
46
    public function method()
 
47
    {
 
48
        $any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
 
49
        $expects = $this->expects($any);
 
50
        return call_user_func_array(array($expects, 'method'), func_get_args());
 
51
    }
 
52
 
 
53
    public function __phpunit_setOriginalObject($originalObject)
 
54
    {
 
55
        $this->__phpunit_originalObject = $originalObject;
 
56
    }
 
57
 
 
58
    public function __phpunit_getInvocationMocker()
 
59
    {
 
60
        if ($this->__phpunit_invocationMocker === NULL) {
 
61
            $this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
 
62
        }
 
63
 
 
64
        return $this->__phpunit_invocationMocker;
 
65
    }
 
66
 
 
67
    public function __phpunit_hasMatchers()
 
68
    {
 
69
        return $this->__phpunit_getInvocationMocker()->hasMatchers();
 
70
    }
 
71
 
 
72
    public function __phpunit_verify()
 
73
    {
 
74
        $this->__phpunit_getInvocationMocker()->verify();
 
75
        $this->__phpunit_invocationMocker = NULL;
 
76
    }
 
77
}