Skip to content

Instantly share code, notes, and snippets.

@liuggio
Last active December 24, 2015 08:29
Show Gist options
  • Save liuggio/6770837 to your computer and use it in GitHub Desktop.
Save liuggio/6770837 to your computer and use it in GitHub Desktop.
problem with generator during eval
<?php
// with $this->serializer = $this->getMock('Symfony\Component\Serializer\SerializerInterface');
// the $code content into the eval($code) into phpunit/phpunit-mock-objects/PHPUnit/Framework/MockObject/Generator.php
class Mock_SerializerInterface_ec3da84e implements PHPUnit_Framework_MockObject_MockObject, JMS\Serializer\SerializerInterface
{
private static $__phpunit_staticInvocationMocker;
private $__phpunit_invocationMocker;
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
}
public function serialize($data, $format, JMS\Serializer\SerializationContext $context = NULL)
{
$arguments = array($data, $format, $context);
$count = func_num_args();
if ($count > 3) {
$_arguments = func_get_args();
for ($i = 3; $i < $count; $i++) {
$arguments[] = $_arguments[$i];
}
}
$result = $this->__phpunit_getInvocationMocker()->invoke(
new PHPUnit_Framework_MockObject_Invocation_Object(
'JMS\Serializer\SerializerInterface', 'serialize', $arguments, $this, FALSE
)
);
return $result;
}
public function deserialize($data, $type, $format, JMS\Serializer\DeserializationContext $context = NULL)
{
$arguments = array($data, $type, $format, $context);
$count = func_num_args();
if ($count > 4) {
$_arguments = func_get_args();
for ($i = 4; $i < $count; $i++) {
$arguments[] = $_arguments[$i];
}
}
$result = $this->__phpunit_getInvocationMocker()->invoke(
new PHPUnit_Framework_MockObject_Invocation_Object(
'JMS\Serializer\SerializerInterface', 'deserialize', $arguments, $this, FALSE
)
);
return $result;
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return self::__phpunit_getStaticInvocationMocker()->expects($matcher);
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === NULL) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return $this->__phpunit_invocationMocker;
}
public static function __phpunit_getStaticInvocationMocker()
{
if (self::$__phpunit_staticInvocationMocker === NULL) {
self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return self::$__phpunit_staticInvocationMocker;
}
public function __phpunit_hasMatchers()
{
return self::__phpunit_getStaticInvocationMocker()->hasMatchers() ||
$this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify()
{
self::__phpunit_getStaticInvocationMocker()->verify();
$this->__phpunit_getInvocationMocker()->verify();
}
public function __phpunit_cleanup()
{
self::$__phpunit_staticInvocationMocker = NULL;
$this->__phpunit_invocationMocker = NULL;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment