8000 [ProxyManager] Cleanup fixtures by nicolas-grekas · Pull Request #23689 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[ProxyManager] Cleanup fixtures #23689

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[ProxyManager] Cleanup fixtures
  • Loading branch information
nicolas-grekas committed Jul 27, 2017
commit 31843d6f9830835fe9110d9bb4f3234e9056ee5d
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,9 @@ class PhpDumperTest extends TestCase
{
public function testDumpContainerWithProxyService()
{
$container = new ContainerBuilder();

$container->register('foo', 'stdClass');
$container->getDefinition('foo')->setLazy(true);
$container->compile();

$dumper = new PhpDumper($container);

$dumper->setProxyDumper(new ProxyDumper());

$dumpedString = $dumper->dump();

$this->assertStringMatchesFormatFile(
__DIR__.'/../Fixtures/php/lazy_service_structure.txt',
$dumpedString,
$this->dumpLazyServiceProjectServiceContainer(),
'->dump() does generate proxy lazy loading logic.'
);
}
Expand All @@ -50,18 +38,15 @@ public function testDumpContainerWithProxyService()
*/
public function testDumpContainerWithProxyServiceWillShareProxies()
{
// detecting ProxyManager v2
if (class_exists('ProxyManager\ProxyGenerator\LazyLoading\MethodGenerator\StaticProxyConstructor')) {
require_once __DIR__.'/../Fixtures/php/lazy_service_with_hints.php';
} else {
require_once __DIR__.'/../Fixtures/php/lazy_service.php';
if (!class_exists('LazyServiceProjectServiceContainer', false)) {
eval('?>'.$this->dumpLazyServiceProjectServiceContainer());
}

$container = new \LazyServiceProjectServiceContainer();

/* @var $proxy \stdClass_c1d194250ee2e2b7d2eab8b8212368a8 */
$proxy = $container->get('foo');
$this->assertInstanceOf('stdClass_c1d194250ee2e2b7d2eab8b8212368a8', $proxy);
$this->assertInstanceOf('stdClass', $proxy);
$this->assertInstanceOf('ProxyManager\Proxy\LazyLoadingInterface', $proxy);
$this->assertSame($proxy, $container->get('foo'));

$this->assertFalse($proxy->isProxyInitialized());
Expand All @@ -71,4 +56,19 @@ public function testDumpContainerWithProxyServiceWillShareProxies()
$this->assertTrue($proxy->isProxyInitialized());
$this->assertSame($proxy, $container->get('foo'));
}

private function dumpLazyServiceProjectServiceContainer()
{
$container = new ContainerBuilder();

$container->register('foo', 'stdClass');
$container->getDefinition('foo')->setLazy(true);
$container->compile();

$dumper = new PhpDumper($container);

$dumper->setProxyDumper(new ProxyDumper());

return $dumper->dump(array('class' => 'LazyServiceProjectServiceContainer'));
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

use %a
class ProjectServiceContainer extends Container
class LazyServiceProjectServiceContainer extends Container
{%a
public function getFooService($lazyLoad = true)
{
Expand Down
Loading
0