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

« back to all changes in this revision

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