first commit
This commit is contained in:
9
vendor/ocramius/proxy-manager/tests/language-feature-scripts/README.md
vendored
Normal file
9
vendor/ocramius/proxy-manager/tests/language-feature-scripts/README.md
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
## Integration tests for PHP language features of proxies
|
||||
|
||||
Since proxies are quire complex code, this directory is dedicated
|
||||
to integration tests that are supposed to cause fatal errors or
|
||||
failures in general that are hard to handle in traditional
|
||||
PHPUnit test cases.
|
||||
|
||||
You may find a guide on how to write `.phpt` tests on the
|
||||
[PHP QA website](http://qa.php.net/write-test.php).
|
||||
@@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
Verifies that generated access interceptors disallow private property direct isset check
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
class Kitchen
|
||||
{
|
||||
private $sweets = 'candy';
|
||||
}
|
||||
|
||||
$factory = new \ProxyManager\Factory\AccessInterceptorValueHolderFactory($configuration);
|
||||
|
||||
$proxy = $factory->createProxy(new Kitchen());
|
||||
|
||||
var_dump(isset($proxy->sweets));
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(false)
|
||||
@@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
Verifies that generated access interceptors disallow private property direct read
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
class Kitchen
|
||||
{
|
||||
private $sweets;
|
||||
}
|
||||
|
||||
$factory = new \ProxyManager\Factory\AccessInterceptorValueHolderFactory($configuration);
|
||||
|
||||
$proxy = $factory->createProxy(new Kitchen());
|
||||
|
||||
$proxy->sweets;
|
||||
?>
|
||||
--EXPECTF--
|
||||
%SFatal error: Cannot access private property %s::$sweets in %s on line %d
|
||||
@@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
Verifies that generated access interceptors disallow private property direct unset
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
class Kitchen
|
||||
{
|
||||
private $sweets;
|
||||
}
|
||||
|
||||
$factory = new \ProxyManager\Factory\AccessInterceptorValueHolderFactory($configuration);
|
||||
|
||||
$proxy = $factory->createProxy(new Kitchen());
|
||||
|
||||
unset($proxy->sweets);
|
||||
?>
|
||||
--EXPECTF--
|
||||
%SFatal error: Cannot %s property %s on line %d
|
||||
@@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
Verifies that generated access interceptors disallow private property direct write
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
class Kitchen
|
||||
{
|
||||
private $sweets;
|
||||
}
|
||||
|
||||
$factory = new \ProxyManager\Factory\AccessInterceptorValueHolderFactory($configuration);
|
||||
|
||||
$proxy = $factory->createProxy(new Kitchen());
|
||||
|
||||
$proxy->sweets = 'stolen';
|
||||
?>
|
||||
--EXPECTF--
|
||||
%SFatal error: Cannot access %s property%S in %s on line %d
|
||||
@@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
Verifies that generated access interceptors disallow protected property direct isset check
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
class Kitchen
|
||||
{
|
||||
protected $sweets = 'candy';
|
||||
}
|
||||
|
||||
$factory = new \ProxyManager\Factory\AccessInterceptorValueHolderFactory($configuration);
|
||||
|
||||
$proxy = $factory->createProxy(new Kitchen());
|
||||
|
||||
var_dump(isset($proxy->sweets));
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(false)
|
||||
@@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
Verifies that generated access interceptors disallow protected property direct read
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
class Kitchen
|
||||
{
|
||||
protected $sweets;
|
||||
}
|
||||
|
||||
$factory = new \ProxyManager\Factory\AccessInterceptorValueHolderFactory($configuration);
|
||||
|
||||
$proxy = $factory->createProxy(new Kitchen());
|
||||
|
||||
$proxy->sweets;
|
||||
?>
|
||||
--EXPECTF--
|
||||
%SFatal error: Cannot access protected property %s::$sweets in %s on line %d
|
||||
@@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
Verifies that generated access interceptors disallow protected property direct unset
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
class Kitchen
|
||||
{
|
||||
protected $sweets;
|
||||
}
|
||||
|
||||
$factory = new \ProxyManager\Factory\AccessInterceptorValueHolderFactory($configuration);
|
||||
|
||||
$proxy = $factory->createProxy(new Kitchen());
|
||||
|
||||
unset($proxy->sweets);
|
||||
?>
|
||||
--EXPECTF--
|
||||
%SFatal error: Cannot %s property%sin %s on line %d
|
||||
@@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
Verifies that generated access interceptors disallow protected property direct write
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
class Kitchen
|
||||
{
|
||||
protected $sweets;
|
||||
}
|
||||
|
||||
$factory = new \ProxyManager\Factory\AccessInterceptorValueHolderFactory($configuration);
|
||||
|
||||
$proxy = $factory->createProxy(new Kitchen());
|
||||
|
||||
$proxy->sweets = 'stolen';
|
||||
?>
|
||||
--EXPECTF--
|
||||
%SFatal error: Cannot %s property%sin %s on line %d
|
||||
@@ -0,0 +1,26 @@
|
||||
--TEST--
|
||||
Verifies that generated access interceptors disallow private property direct isset check
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (! method_exists('Closure', 'bind')) {
|
||||
echo 'skip PHP 5.4+ is needed to localize private properties';
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
class Kitchen
|
||||
{
|
||||
private $sweets = 'candy';
|
||||
}
|
||||
|
||||
$factory = new \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory($configuration);
|
||||
|
||||
$proxy = $factory->createProxy(new Kitchen());
|
||||
|
||||
var_dump(isset($proxy->sweets));
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(false)
|
||||
@@ -0,0 +1,26 @@
|
||||
--TEST--
|
||||
Verifies that generated access interceptors disallow private property direct read
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (! method_exists('Closure', 'bind')) {
|
||||
echo 'skip PHP 5.4+ is needed to localize private properties';
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
class Kitchen
|
||||
{
|
||||
private $sweets;
|
||||
}
|
||||
|
||||
$factory = new \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory($configuration);
|
||||
|
||||
$proxy = $factory->createProxy(new Kitchen());
|
||||
|
||||
$proxy->sweets;
|
||||
?>
|
||||
--EXPECTF--
|
||||
%SFatal error: Cannot access private property %s::$sweets in %s on line %d
|
||||
@@ -0,0 +1,26 @@
|
||||
--TEST--
|
||||
Verifies that generated access interceptors disallow private property direct unset
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (! method_exists('Closure', 'bind')) {
|
||||
echo 'skip PHP 5.4+ is needed to localize private properties';
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
class Kitchen
|
||||
{
|
||||
private $sweets;
|
||||
}
|
||||
|
||||
$factory = new \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory($configuration);
|
||||
|
||||
$proxy = $factory->createProxy(new Kitchen());
|
||||
|
||||
unset($proxy->sweets);
|
||||
?>
|
||||
--EXPECTF--
|
||||
%SFatal error: Cannot %s property%sin %s on line %d
|
||||
@@ -0,0 +1,26 @@
|
||||
--TEST--
|
||||
Verifies that generated access interceptors disallow private property direct write
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (! method_exists('Closure', 'bind')) {
|
||||
echo 'skip PHP 5.4+ is needed to localize private properties';
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
class Kitchen
|
||||
{
|
||||
private $sweets;
|
||||
}
|
||||
|
||||
$factory = new \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory($configuration);
|
||||
|
||||
$proxy = $factory->createProxy(new Kitchen());
|
||||
|
||||
$proxy->sweets = 'stolen';
|
||||
?>
|
||||
--EXPECTF--
|
||||
%SFatal error: Cannot %s property%sin %s on line %d
|
||||
@@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
Verifies that generated access interceptors disallow protected property direct isset check
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
class Kitchen
|
||||
{
|
||||
protected $sweets = 'candy';
|
||||
}
|
||||
|
||||
$factory = new \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory($configuration);
|
||||
|
||||
$proxy = $factory->createProxy(new Kitchen());
|
||||
|
||||
var_dump(isset($proxy->sweets));
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(false)
|
||||
@@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
Verifies that generated access interceptors disallow protected property direct read
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
class Kitchen
|
||||
{
|
||||
protected $sweets;
|
||||
}
|
||||
|
||||
$factory = new \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory($configuration);
|
||||
|
||||
$proxy = $factory->createProxy(new Kitchen());
|
||||
|
||||
$proxy->sweets;
|
||||
?>
|
||||
--EXPECTF--
|
||||
%SFatal error: Cannot access protected property %s::$sweets in %s on line %d
|
||||
@@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
Verifies that generated access interceptors disallow protected property direct unset
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
class Kitchen
|
||||
{
|
||||
protected $sweets;
|
||||
}
|
||||
|
||||
$factory = new \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory($configuration);
|
||||
|
||||
$proxy = $factory->createProxy(new Kitchen());
|
||||
|
||||
unset($proxy->sweets);
|
||||
?>
|
||||
--EXPECTF--
|
||||
%SFatal error: Cannot %s property%sin %s on line %d
|
||||
@@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
Verifies that generated access interceptors disallow protected property direct write
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
class Kitchen
|
||||
{
|
||||
protected $sweets;
|
||||
}
|
||||
|
||||
$factory = new \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory($configuration);
|
||||
|
||||
$proxy = $factory->createProxy(new Kitchen());
|
||||
|
||||
$proxy->sweets = 'stolen';
|
||||
?>
|
||||
--EXPECTF--
|
||||
%SFatal error: Cannot %s property%sin %s on line %d
|
||||
34
vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-with-cache.phpt
vendored
Normal file
34
vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-with-cache.phpt
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
--TEST--
|
||||
Verifies that access interceptor proxy file is generated
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
class Kitchen
|
||||
{
|
||||
private $sweets = 'candy';
|
||||
}
|
||||
|
||||
$configuration->setProxiesTargetDir(__DIR__ . '/cache');
|
||||
$fileLocator = new \ProxyManager\FileLocator\FileLocator($configuration->getProxiesTargetDir());
|
||||
$configuration->setGeneratorStrategy(
|
||||
new \ProxyManager\GeneratorStrategy\FileWriterGeneratorStrategy($fileLocator)
|
||||
);
|
||||
|
||||
$factory = new \ProxyManager\Factory\AccessInterceptorValueHolderFactory($configuration);
|
||||
|
||||
$proxy = $factory->createProxy(new Kitchen());
|
||||
|
||||
$filename = $fileLocator->getProxyFileName(get_class($proxy));
|
||||
var_dump(file_exists($filename));
|
||||
|
||||
$proxy = $factory->createProxy(new Kitchen());
|
||||
|
||||
var_dump(file_exists($filename));
|
||||
@unlink($filename);
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
bool(true)
|
||||
3
vendor/ocramius/proxy-manager/tests/language-feature-scripts/cache/README.md
vendored
Normal file
3
vendor/ocramius/proxy-manager/tests/language-feature-scripts/cache/README.md
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
## Integration tests for PHP language features of proxies
|
||||
|
||||
This folder is used for the caches
|
||||
10
vendor/ocramius/proxy-manager/tests/language-feature-scripts/init.php
vendored
Normal file
10
vendor/ocramius/proxy-manager/tests/language-feature-scripts/init.php
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
use ProxyManager\Configuration;
|
||||
use ProxyManager\GeneratorStrategy\EvaluatingGeneratorStrategy;
|
||||
|
||||
require_once __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$configuration = new Configuration();
|
||||
|
||||
$configuration->setGeneratorStrategy(new EvaluatingGeneratorStrategy());
|
||||
@@ -0,0 +1,25 @@
|
||||
--TEST--
|
||||
Verifies that generated lazy loading ghost objects disallow reading non-existing properties via direct read
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
class Kitchen
|
||||
{
|
||||
private $sweets;
|
||||
|
||||
public function & __get($name)
|
||||
{
|
||||
return $name;
|
||||
}
|
||||
}
|
||||
|
||||
$factory = new \ProxyManager\Factory\LazyLoadingGhostFactory($configuration);
|
||||
|
||||
$proxy = $factory->createProxy('Kitchen', function () {});
|
||||
|
||||
echo $proxy->nonExisting;
|
||||
?>
|
||||
--EXPECTF--
|
||||
nonExisting
|
||||
@@ -0,0 +1,21 @@
|
||||
--TEST--
|
||||
Verifies that generated lazy loading ghost objects disallow reading non-existing properties via direct read
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
class Kitchen
|
||||
{
|
||||
private $sweets;
|
||||
}
|
||||
|
||||
$factory = new \ProxyManager\Factory\LazyLoadingGhostFactory($configuration);
|
||||
|
||||
$proxy = $factory->createProxy('Kitchen', function () {});
|
||||
|
||||
$proxy->nonExisting = 'I do not exist';
|
||||
echo $proxy->nonExisting;
|
||||
?>
|
||||
--EXPECTF--
|
||||
I do not exist
|
||||
@@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
Verifies that generated lazy loading ghost objects disallow reading non-existing properties via direct read
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
class Kitchen
|
||||
{
|
||||
private $sweets;
|
||||
}
|
||||
|
||||
$factory = new \ProxyManager\Factory\LazyLoadingGhostFactory($configuration);
|
||||
|
||||
$proxy = $factory->createProxy('Kitchen', function () {});
|
||||
|
||||
$proxy->nonExisting;
|
||||
?>
|
||||
--EXPECTF--
|
||||
%SNotice: Undefined property: Kitchen::$nonExisting in %s on line %d
|
||||
@@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
Verifies that generated lazy loading ghost objects disallow private property direct isset check
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
class Kitchen
|
||||
{
|
||||
private $sweets = 'candy';
|
||||
}
|
||||
|
||||
$factory = new \ProxyManager\Factory\LazyLoadingGhostFactory($configuration);
|
||||
|
||||
$proxy = $factory->createProxy('Kitchen', function () {});
|
||||
|
||||
var_dump(isset($proxy->sweets));
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(false)
|
||||
@@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
Verifies that generated lazy loading ghost objects disallow private property direct read
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
class Kitchen
|
||||
{
|
||||
private $sweets;
|
||||
}
|
||||
|
||||
$factory = new \ProxyManager\Factory\LazyLoadingGhostFactory($configuration);
|
||||
|
||||
$proxy = $factory->createProxy('Kitchen', function () {});
|
||||
|
||||
$proxy->sweets;
|
||||
?>
|
||||
--EXPECTF--
|
||||
%SFatal error: Cannot access private property %s::$sweets in %s on line %d
|
||||
@@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
Verifies that generated lazy loading ghost objects disallow private property direct unset
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
class Kitchen
|
||||
{
|
||||
private $sweets;
|
||||
}
|
||||
|
||||
$factory = new \ProxyManager\Factory\LazyLoadingGhostFactory($configuration);
|
||||
|
||||
$proxy = $factory->createProxy('Kitchen', function () {});
|
||||
|
||||
unset($proxy->sweets);
|
||||
?>
|
||||
--EXPECTF--
|
||||
%SFatal error: Cannot %s property %s on line %d
|
||||
@@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
Verifies that generated lazy loading ghost objects disallow private property direct write
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
class Kitchen
|
||||
{
|
||||
private $sweets;
|
||||
}
|
||||
|
||||
$factory = new \ProxyManager\Factory\LazyLoadingGhostFactory($configuration);
|
||||
|
||||
$proxy = $factory->createProxy('Kitchen', function () {});
|
||||
|
||||
$proxy->sweets = 'stolen';
|
||||
?>
|
||||
--EXPECTF--
|
||||
%SFatal error: Cannot access %s property%S in %s on line %d
|
||||
@@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
Verifies that generated lazy loading ghost objects disallow protected property direct isset check
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
class Kitchen
|
||||
{
|
||||
protected $sweets = 'candy';
|
||||
}
|
||||
|
||||
$factory = new \ProxyManager\Factory\LazyLoadingGhostFactory($configuration);
|
||||
|
||||
$proxy = $factory->createProxy('Kitchen', function () {});
|
||||
|
||||
var_dump(isset($proxy->sweets));
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(false)
|
||||
@@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
Verifies that generated lazy loading ghost objects disallow protected property direct read
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
class Kitchen
|
||||
{
|
||||
protected $sweets;
|
||||
}
|
||||
|
||||
$factory = new \ProxyManager\Factory\LazyLoadingGhostFactory($configuration);
|
||||
|
||||
$proxy = $factory->createProxy('Kitchen', function () {});
|
||||
|
||||
$proxy->sweets;
|
||||
?>
|
||||
--EXPECTF--
|
||||
%SFatal error: Cannot access protected property %s::$sweets in %s on line %d
|
||||
@@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
Verifies that generated lazy loading ghost objects disallow protected property direct unset
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
class Kitchen
|
||||
{
|
||||
protected $sweets;
|
||||
}
|
||||
|
||||
$factory = new \ProxyManager\Factory\LazyLoadingGhostFactory($configuration);
|
||||
|
||||
$proxy = $factory->createProxy('Kitchen', function () {});
|
||||
|
||||
unset($proxy->sweets);
|
||||
?>
|
||||
--EXPECTF--
|
||||
%SFatal error: Cannot %s property%sin %s on line %d
|
||||
@@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
Verifies that generated lazy loading ghost objects disallow protected property direct write
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
class Kitchen
|
||||
{
|
||||
protected $sweets;
|
||||
}
|
||||
|
||||
$factory = new \ProxyManager\Factory\LazyLoadingGhostFactory($configuration);
|
||||
|
||||
$proxy = $factory->createProxy('Kitchen', function () {});
|
||||
|
||||
$proxy->sweets = 'stolen';
|
||||
?>
|
||||
--EXPECTF--
|
||||
%SFatal error: Cannot %s property%sin %s on line %d
|
||||
34
vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-with-cache.phpt
vendored
Normal file
34
vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-with-cache.phpt
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
--TEST--
|
||||
Verifies that lazy loading ghost proxy file is generated
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
class Kitchen
|
||||
{
|
||||
private $sweets = 'candy';
|
||||
}
|
||||
|
||||
$configuration->setProxiesTargetDir(__DIR__ . '/cache');
|
||||
$fileLocator = new \ProxyManager\FileLocator\FileLocator($configuration->getProxiesTargetDir());
|
||||
$configuration->setGeneratorStrategy(
|
||||
new \ProxyManager\GeneratorStrategy\FileWriterGeneratorStrategy($fileLocator)
|
||||
);
|
||||
|
||||
$factory = new \ProxyManager\Factory\LazyLoadingGhostFactory($configuration);
|
||||
|
||||
$proxy = $factory->createProxy('Kitchen', function () {});
|
||||
|
||||
$filename = $fileLocator->getProxyFileName(get_class($proxy));
|
||||
var_dump(file_exists($filename));
|
||||
|
||||
$proxy = $factory->createProxy('Kitchen', function () {});
|
||||
|
||||
var_dump(file_exists($filename));
|
||||
@unlink($filename);
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
bool(true)
|
||||
@@ -0,0 +1,23 @@
|
||||
--TEST--
|
||||
Verifies that generated lazy loading value holders disallow private property direct isset check
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
class Kitchen
|
||||
{
|
||||
private $sweets = 'candy';
|
||||
}
|
||||
|
||||
$factory = new \ProxyManager\Factory\LazyLoadingValueHolderFactory($configuration);
|
||||
|
||||
$proxy = $factory->createProxy('Kitchen', function (& $wrapped, $proxy, $method, array $parameters, & $initializer) {
|
||||
$initializer = null;
|
||||
$wrapped = new Kitchen();
|
||||
});
|
||||
|
||||
var_dump(isset($proxy->sweets));
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(false)
|
||||
@@ -0,0 +1,23 @@
|
||||
--TEST--
|
||||
Verifies that generated lazy loading value holders disallow private property direct read
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
class Kitchen
|
||||
{
|
||||
private $sweets;
|
||||
}
|
||||
|
||||
$factory = new \ProxyManager\Factory\LazyLoadingValueHolderFactory($configuration);
|
||||
|
||||
$proxy = $factory->createProxy('Kitchen', function (& $wrapped, $proxy, $method, array $parameters, & $initializer) {
|
||||
$initializer = null;
|
||||
$wrapped = new Kitchen();
|
||||
});
|
||||
|
||||
$proxy->sweets;
|
||||
?>
|
||||
--EXPECTF--
|
||||
%SFatal error: Cannot access private property %s::$sweets in %s on line %d
|
||||
@@ -0,0 +1,23 @@
|
||||
--TEST--
|
||||
Verifies that generated lazy loading value holders disallow private property direct unset
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
class Kitchen
|
||||
{
|
||||
private $sweets;
|
||||
}
|
||||
|
||||
$factory = new \ProxyManager\Factory\LazyLoadingValueHolderFactory($configuration);
|
||||
|
||||
$proxy = $factory->createProxy('Kitchen', function (& $wrapped, $proxy, $method, array $parameters, & $initializer) {
|
||||
$initializer = null;
|
||||
$wrapped = new Kitchen();
|
||||
});
|
||||
|
||||
unset($proxy->sweets);
|
||||
?>
|
||||
--EXPECTF--
|
||||
%SFatal error: Cannot %s property %s on line %d
|
||||
@@ -0,0 +1,23 @@
|
||||
--TEST--
|
||||
Verifies that generated lazy loading value holders disallow private property direct write
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
class Kitchen
|
||||
{
|
||||
private $sweets;
|
||||
}
|
||||
|
||||
$factory = new \ProxyManager\Factory\LazyLoadingValueHolderFactory($configuration);
|
||||
|
||||
$proxy = $factory->createProxy('Kitchen', function (& $wrapped, $proxy, $method, array $parameters, & $initializer) {
|
||||
$initializer = null;
|
||||
$wrapped = new Kitchen();
|
||||
});
|
||||
|
||||
$proxy->sweets = 'stolen';
|
||||
?>
|
||||
--EXPECTF--
|
||||
%SFatal error: Cannot access %s property %s on line %d
|
||||
@@ -0,0 +1,23 @@
|
||||
--TEST--
|
||||
Verifies that generated lazy loading value holders disallow protected property direct isset check
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
class Kitchen
|
||||
{
|
||||
protected $sweets = 'candy';
|
||||
}
|
||||
|
||||
$factory = new \ProxyManager\Factory\LazyLoadingValueHolderFactory($configuration);
|
||||
|
||||
$proxy = $factory->createProxy('Kitchen', function (& $wrapped, $proxy, $method, array $parameters, & $initializer) {
|
||||
$initializer = null;
|
||||
$wrapped = new Kitchen();
|
||||
});
|
||||
|
||||
var_dump(isset($proxy->sweets));
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(false)
|
||||
@@ -0,0 +1,23 @@
|
||||
--TEST--
|
||||
Verifies that generated lazy loading value holders disallow protected property direct read
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
class Kitchen
|
||||
{
|
||||
protected $sweets;
|
||||
}
|
||||
|
||||
$factory = new \ProxyManager\Factory\LazyLoadingValueHolderFactory($configuration);
|
||||
|
||||
$proxy = $factory->createProxy('Kitchen', function (& $wrapped, $proxy, $method, array $parameters, & $initializer) {
|
||||
$initializer = null;
|
||||
$wrapped = new Kitchen();
|
||||
});
|
||||
|
||||
$proxy->sweets;
|
||||
?>
|
||||
--EXPECTF--
|
||||
%SFatal error: Cannot access protected property %s::$sweets in %s on line %d
|
||||
@@ -0,0 +1,23 @@
|
||||
--TEST--
|
||||
Verifies that generated lazy loading value holders disallow protected property direct unset
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
class Kitchen
|
||||
{
|
||||
protected $sweets;
|
||||
}
|
||||
|
||||
$factory = new \ProxyManager\Factory\LazyLoadingValueHolderFactory($configuration);
|
||||
|
||||
$proxy = $factory->createProxy('Kitchen', function (& $wrapped, $proxy, $method, array $parameters, & $initializer) {
|
||||
$initializer = null;
|
||||
$wrapped = new Kitchen();
|
||||
});
|
||||
|
||||
unset($proxy->sweets);
|
||||
?>
|
||||
--EXPECTF--
|
||||
%SFatal error: Cannot %s property%sin %s on line %d
|
||||
@@ -0,0 +1,23 @@
|
||||
--TEST--
|
||||
Verifies that generated lazy loading value holders disallow protected property direct write
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
class Kitchen
|
||||
{
|
||||
protected $sweets;
|
||||
}
|
||||
|
||||
$factory = new \ProxyManager\Factory\LazyLoadingValueHolderFactory($configuration);
|
||||
|
||||
$proxy = $factory->createProxy('Kitchen', function (& $wrapped, $proxy, $method, array $parameters, & $initializer) {
|
||||
$initializer = null;
|
||||
$wrapped = new Kitchen();
|
||||
});
|
||||
|
||||
$proxy->sweets = 'stolen';
|
||||
?>
|
||||
--EXPECTF--
|
||||
%SFatal error: Cannot %s property%sin %s on line %d
|
||||
@@ -0,0 +1,31 @@
|
||||
--TEST--
|
||||
Verifies that lazy loading value holder factory can generate proxy for PHP core classes.
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
class PharMock extends Phar
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public function compress($compression_type, $file_ext = null)
|
||||
{
|
||||
echo $compression_type;
|
||||
}
|
||||
}
|
||||
|
||||
$factory = new \ProxyManager\Factory\LazyLoadingValueHolderFactory($configuration);
|
||||
|
||||
$factory
|
||||
->createProxy('Phar', function (& $wrapped, $proxy, $method, array $parameters, & $initializer) {
|
||||
$initializer = null;
|
||||
$wrapped = new PharMock();
|
||||
})
|
||||
->compress('Lazy Loaded!');
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
Lazy Loaded!
|
||||
@@ -0,0 +1,40 @@
|
||||
--TEST--
|
||||
Verifies that lazy loading value holder proxy file is generated
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
class Kitchen
|
||||
{
|
||||
private $sweets = 'candy';
|
||||
}
|
||||
|
||||
$configuration->setProxiesTargetDir(__DIR__ . '/cache');
|
||||
$fileLocator = new \ProxyManager\FileLocator\FileLocator($configuration->getProxiesTargetDir());
|
||||
$configuration->setGeneratorStrategy(
|
||||
new \ProxyManager\GeneratorStrategy\FileWriterGeneratorStrategy($fileLocator)
|
||||
);
|
||||
|
||||
$factory = new \ProxyManager\Factory\LazyLoadingValueHolderFactory($configuration);
|
||||
|
||||
$proxy = $factory->createProxy('Kitchen', function (& $wrapped, $proxy, $method, array $parameters, & $initializer) {
|
||||
$initializer = null;
|
||||
$wrapped = new Kitchen();
|
||||
});
|
||||
|
||||
$filename = $fileLocator->getProxyFileName(get_class($proxy));
|
||||
var_dump(file_exists($filename));
|
||||
|
||||
$proxy = $factory->createProxy('Kitchen', function (& $wrapped, $proxy, $method, array $parameters, & $initializer) {
|
||||
$initializer = null;
|
||||
$wrapped = new Kitchen();
|
||||
});
|
||||
|
||||
var_dump(file_exists($filename));
|
||||
@unlink($filename);
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
bool(true)
|
||||
@@ -0,0 +1,23 @@
|
||||
--TEST--
|
||||
Verifies that generated null object disallow public function
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
class Kitchen
|
||||
{
|
||||
public function foo()
|
||||
{
|
||||
return 'bar';
|
||||
}
|
||||
}
|
||||
|
||||
$factory = new \ProxyManager\Factory\NullObjectFactory($configuration);
|
||||
|
||||
$proxy = $factory->createProxy('Kitchen');
|
||||
|
||||
var_dump($proxy->foo());
|
||||
?>
|
||||
--EXPECT--
|
||||
NULL
|
||||
@@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
Verifies that generated null object disallow public function
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
class Kitchen
|
||||
{
|
||||
public $foo = 'bar';
|
||||
}
|
||||
|
||||
$factory = new \ProxyManager\Factory\NullObjectFactory($configuration);
|
||||
|
||||
$proxy = $factory->createProxy('Kitchen');
|
||||
|
||||
var_dump($proxy->foo);
|
||||
?>
|
||||
--EXPECT--
|
||||
NULL
|
||||
@@ -0,0 +1,43 @@
|
||||
--TEST--
|
||||
Verifies that generated remote object can call public property
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
use ProxyManager\Factory\RemoteObject\AdapterInterface;
|
||||
use Zend\Json\Server\Client;
|
||||
|
||||
interface FooServiceInterface
|
||||
{
|
||||
public function foo();
|
||||
}
|
||||
|
||||
class Foo implements FooServiceInterface
|
||||
{
|
||||
public $foo = "baz";
|
||||
|
||||
public function foo()
|
||||
{
|
||||
return 'bar';
|
||||
}
|
||||
}
|
||||
|
||||
class CustomAdapter implements AdapterInterface
|
||||
{
|
||||
public function call($wrappedClass, $method, array $params = array())
|
||||
{
|
||||
return 'baz';
|
||||
}
|
||||
}
|
||||
|
||||
$factory = new \ProxyManager\Factory\RemoteObjectFactory(new CustomAdapter(), $configuration);
|
||||
$proxy = $factory->createProxy('ProxyManagerTestAsset\RemoteProxy\FooServiceInterface');
|
||||
|
||||
var_dump($proxy->foo());
|
||||
var_dump($proxy->unknown());
|
||||
?>
|
||||
--EXPECTF--
|
||||
string(3) "baz"
|
||||
|
||||
%SFatal error: Call to undefined method %s::unknown%S in %s on line %d
|
||||
Reference in New Issue
Block a user