Skip to content

Commit

Permalink
Test that AccessInterceptorScope doesn't throw Serialized class Erron…
Browse files Browse the repository at this point in the history
…eous data PHP warning
  • Loading branch information
Ludo444 authored and Ocramius committed Dec 17, 2019
1 parent bcec33b commit b7bac96
Show file tree
Hide file tree
Showing 8 changed files with 240 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
--TEST--
Verifies that generated access interceptors doesn't throw PHP Warning on Serialized class private property direct isset check
--FILE--
<?php

require_once __DIR__ . '/init.php';

class Kitchen implements \Serializable
{
private $sweets = 'candy';

function serialize()
{
return $this->sweets;
}

function unserialize($serialized)
{
$this->sweets = $serialized;
}
}

$factory = new \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory($configuration);

$proxy = $factory->createProxy(new Kitchen());

var_dump(isset($proxy->sweets));
?>
--EXPECT--
bool(false)
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
--TEST--
Verifies that generated access interceptors doesn't throw PHP Warning on Serialized class private property direct read
--FILE--
<?php

require_once __DIR__ . '/init.php';

class Kitchen implements \Serializable
{
private $sweets = 'candy';

function serialize()
{
return $this->sweets;
}

function unserialize($serialized)
{
$this->sweets = $serialized;
}
}

$factory = new \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory($configuration);

$proxy = $factory->createProxy(new Kitchen());

$proxy->sweets;
?>
--EXPECTF--
%SFatal error:%sCannot access private property %s::$sweets in %a
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
--TEST--
Verifies that generated access interceptors doesn't throw PHP Warning on Serialized class private property direct unset
--FILE--
<?php

require_once __DIR__ . '/init.php';

class Kitchen implements \Serializable
{
private $sweets = 'candy';

function serialize()
{
return $this->sweets;
}

function unserialize($serialized)
{
$this->sweets = $serialized;
}
}

$factory = new \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory($configuration);

$proxy = $factory->createProxy(new Kitchen());

unset($proxy->sweets);
?>
--EXPECTF--
%SFatal error:%sCannot %s property%sin %a
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
--TEST--
Verifies that generated access interceptors doesn't throw PHP Warning on Serialized class private property direct write
--FILE--
<?php

require_once __DIR__ . '/init.php';

class Kitchen implements \Serializable
{
private $sweets = 'candy';

function serialize()
{
return $this->sweets;
}

function unserialize($serialized)
{
$this->sweets = $serialized;
}
}

$factory = new \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory($configuration);

$proxy = $factory->createProxy(new Kitchen());

$proxy->sweets = 'stolen';
?>
--EXPECTF--
%SFatal error:%sCannot %s property%sin %a
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
--TEST--
Verifies that generated access interceptors doesn't throw PHP Warning on Serialized class protected property direct isset check
--FILE--
<?php

require_once __DIR__ . '/init.php';

class Kitchen implements \Serializable
{
protected $sweets = 'candy';

function serialize()
{
return $this->sweets;
}

function unserialize($serialized)
{
$this->sweets = $serialized;
}
}

$factory = new \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory($configuration);

$proxy = $factory->createProxy(new Kitchen());

var_dump(isset($proxy->sweets));
?>
--EXPECT--
bool(false)
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
--TEST--
Verifies that generated access interceptors doesn't throw PHP Warning on Serialized class protected property direct read
--FILE--
<?php

require_once __DIR__ . '/init.php';

class Kitchen implements \Serializable
{
protected $sweets = 'candy';

function serialize()
{
return $this->sweets;
}

function unserialize($serialized)
{
$this->sweets = $serialized;
}
}

$factory = new \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory($configuration);

$proxy = $factory->createProxy(new Kitchen());

$proxy->sweets;
?>
--EXPECTF--
%SFatal error:%sCannot access protected property %s::$sweets in %a
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
--TEST--
Verifies that generated access interceptors doesn't throw PHP Warning on Serialized class protected property direct unset
--FILE--
<?php

require_once __DIR__ . '/init.php';

class Kitchen implements \Serializable
{
protected $sweets = 'candy';

function serialize()
{
return $this->sweets;
}

function unserialize($serialized)
{
$this->sweets = $serialized;
}
}

$factory = new \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory($configuration);

$proxy = $factory->createProxy(new Kitchen());

unset($proxy->sweets);
?>
--EXPECTF--
%SFatal error:%sCannot %s property%sin %a
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
--TEST--
Verifies that generated access interceptors doesn't throw PHP Warning on Serialized class protected property direct write
--FILE--
<?php

require_once __DIR__ . '/init.php';

class Kitchen implements \Serializable
{
protected $sweets = 'candy';

function serialize()
{
return $this->sweets;
}

function unserialize($serialized)
{
$this->sweets = $serialized;
}
}

$factory = new \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory($configuration);

$proxy = $factory->createProxy(new Kitchen());

$proxy->sweets = 'stolen';
?>
--EXPECTF--
%SFatal error:%sCannot %s property%sin %a

0 comments on commit b7bac96

Please sign in to comment.