Vendor update && Started using DoctrineMigrations
This commit is contained in:
111
vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Proxy/EnhancerTest.php
vendored
Normal file
111
vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Proxy/EnhancerTest.php
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
namespace CG\Tests\Proxy;
|
||||
|
||||
use CG\Proxy\LazyInitializerInterface;
|
||||
use CG\Proxy\InterceptionGenerator;
|
||||
use CG\Proxy\LazyInitializerGenerator;
|
||||
use CG\Proxy\Enhancer;
|
||||
use CG\Tests\Proxy\Fixture\TraceInterceptor;
|
||||
|
||||
class EnhancerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider getGenerationTests
|
||||
*/
|
||||
public function testGenerateClass($class, $generatedClass, array $interfaces, array $generators)
|
||||
{
|
||||
$enhancer = new Enhancer(new \ReflectionClass($class), $interfaces, $generators);
|
||||
$enhancer->setNamingStrategy($this->getNamingStrategy($generatedClass));
|
||||
|
||||
$this->assertEquals($this->getContent(substr($generatedClass, strrpos($generatedClass, '\\') + 1)), $enhancer->generateClass());
|
||||
}
|
||||
|
||||
public function getGenerationTests()
|
||||
{
|
||||
return array(
|
||||
array('CG\Tests\Proxy\Fixture\SimpleClass', 'CG\Tests\Proxy\Fixture\SimpleClass__CG__Enhanced', array('CG\Tests\Proxy\Fixture\MarkerInterface'), array()),
|
||||
array('CG\Tests\Proxy\Fixture\SimpleClass', 'CG\Tests\Proxy\Fixture\SimpleClass__CG__Sluggable', array('CG\Tests\Proxy\Fixture\SluggableInterface'), array()),
|
||||
array('CG\Tests\Proxy\Fixture\Entity', 'CG\Tests\Proxy\Fixture\Entity__CG__LazyInitializing', array(), array(
|
||||
new LazyInitializerGenerator(),
|
||||
))
|
||||
);
|
||||
}
|
||||
|
||||
public function testInterceptionGenerator()
|
||||
{
|
||||
$enhancer = new Enhancer(new \ReflectionClass('CG\Tests\Proxy\Fixture\Entity'), array(), array(
|
||||
$generator = new InterceptionGenerator()
|
||||
));
|
||||
$enhancer->setNamingStrategy($this->getNamingStrategy('CG\Tests\Proxy\Fixture\Entity__CG__Traceable_'.sha1(microtime(true))));
|
||||
$generator->setPrefix('');
|
||||
|
||||
$traceable = $enhancer->createInstance();
|
||||
$traceable->setLoader($this->getLoader(array(
|
||||
$interceptor1 = new TraceInterceptor(),
|
||||
$interceptor2 = new TraceInterceptor(),
|
||||
)));
|
||||
|
||||
$this->assertEquals('foo', $traceable->getName());
|
||||
$this->assertEquals('foo', $traceable->getName());
|
||||
$this->assertEquals(2, count($interceptor1->getLog()));
|
||||
$this->assertEquals(2, count($interceptor2->getLog()));
|
||||
}
|
||||
|
||||
public function testLazyInitializerGenerator()
|
||||
{
|
||||
$enhancer = new Enhancer(new \ReflectionClass('CG\Tests\Proxy\Fixture\Entity'), array(), array(
|
||||
$generator = new LazyInitializerGenerator(),
|
||||
));
|
||||
$generator->setPrefix('');
|
||||
|
||||
$entity = $enhancer->createInstance();
|
||||
$entity->setLazyInitializer($initializer = new Initializer());
|
||||
$this->assertEquals('foo', $entity->getName());
|
||||
$this->assertSame($entity, $initializer->getLastObject());
|
||||
}
|
||||
|
||||
private function getLoader(array $interceptors)
|
||||
{
|
||||
$loader = $this->getMock('CG\Proxy\InterceptorLoaderInterface');
|
||||
$loader
|
||||
->expects($this->any())
|
||||
->method('loadInterceptors')
|
||||
->will($this->returnValue($interceptors))
|
||||
;
|
||||
|
||||
return $loader;
|
||||
}
|
||||
|
||||
private function getContent($file)
|
||||
{
|
||||
return file_get_contents(__DIR__.'/Fixture/generated/'.$file.'.php.gen');
|
||||
}
|
||||
|
||||
private function getNamingStrategy($name)
|
||||
{
|
||||
$namingStrategy = $this->getMock('CG\Core\NamingStrategyInterface');
|
||||
$namingStrategy
|
||||
->expects($this->any())
|
||||
->method('getClassName')
|
||||
->will($this->returnValue($name))
|
||||
;
|
||||
|
||||
return $namingStrategy;
|
||||
}
|
||||
}
|
||||
|
||||
class Initializer implements LazyInitializerInterface
|
||||
{
|
||||
private $lastObject;
|
||||
|
||||
public function initializeObject($object)
|
||||
{
|
||||
$this->lastObject = $object;
|
||||
}
|
||||
|
||||
public function getLastObject()
|
||||
{
|
||||
return $this->lastObject;
|
||||
}
|
||||
}
|
23
vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Proxy/Fixture/Entity.php
vendored
Normal file
23
vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Proxy/Fixture/Entity.php
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace CG\Tests\Proxy\Fixture;
|
||||
|
||||
class Entity
|
||||
{
|
||||
public function getName()
|
||||
{
|
||||
return 'foo';
|
||||
}
|
||||
|
||||
public final function getBaz()
|
||||
{
|
||||
}
|
||||
|
||||
protected function getFoo()
|
||||
{
|
||||
}
|
||||
|
||||
private function getBar()
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
namespace CG\Tests\Proxy
|
7
vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Proxy/Fixture/MarkerInterface.php
vendored
Normal file
7
vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Proxy/Fixture/MarkerInterface.php
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace CG\Tests\Proxy\Fixture;
|
||||
|
||||
interface MarkerInterface
|
||||
{
|
||||
}
|
7
vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Proxy/Fixture/SimpleClass.php
vendored
Normal file
7
vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Proxy/Fixture/SimpleClass.php
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace CG\Tests\Proxy\Fixture;
|
||||
|
||||
class SimpleClass
|
||||
{
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace CG\Tests\Proxy\Fixture;
|
||||
|
||||
interface SluggableInterface
|
||||
{
|
||||
function getSlug();
|
||||
}
|
29
vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Proxy/Fixture/TraceInterceptor.php
vendored
Normal file
29
vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Proxy/Fixture/TraceInterceptor.php
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace CG\Tests\Proxy\Fixture;
|
||||
|
||||
use CG\Proxy\MethodInvocation;
|
||||
use CG\Proxy\MethodInterceptorInterface;
|
||||
|
||||
class TraceInterceptor implements MethodInterceptorInterface
|
||||
{
|
||||
private $log;
|
||||
|
||||
public function getLog()
|
||||
{
|
||||
return $this->log;
|
||||
}
|
||||
|
||||
public function intercept(MethodInvocation $method)
|
||||
{
|
||||
$message = sprintf('%s::%s(', $method->reflection->class, $method->reflection->name);
|
||||
|
||||
$logArgs = array();
|
||||
foreach ($method->arguments as $arg) {
|
||||
$logArgs[] = var_export($arg, true);
|
||||
}
|
||||
$this->log[] = $message.implode(', ', $logArgs).')';
|
||||
|
||||
return $method->proceed();
|
||||
}
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
namespace CG\Tests\Proxy\Fixture;
|
||||
|
||||
/**
|
||||
* CG library enhanced proxy class.
|
||||
*
|
||||
* This code was generated automatically by the CG library, manual changes to it
|
||||
* will be lost upon next generation.
|
||||
*/
|
||||
class Entity__CG__LazyInitializing extends \CG\Tests\Proxy\Fixture\Entity
|
||||
{
|
||||
private $__CG__lazyInitializer;
|
||||
private $__CG__initialized = false;
|
||||
|
||||
public function getName()
|
||||
{
|
||||
if (false === $this->__CG__initialized) {
|
||||
$this->__CG__initialize();
|
||||
}
|
||||
|
||||
return \CG\Tests\Proxy\Fixture\Entity::getName();
|
||||
}
|
||||
|
||||
public function __CG__setLazyInitializer(\CG\Proxy\LazyInitializerInterface $initializer)
|
||||
{
|
||||
$this->__CG__lazyInitializer = $initializer;
|
||||
}
|
||||
|
||||
private function __CG__initialize()
|
||||
{
|
||||
if (null === $this->__CG__lazyInitializer) {
|
||||
throw new \RuntimeException("__CG__setLazyInitializer() must be called prior to any other public method on this object.");
|
||||
}
|
||||
|
||||
$this->__CG__lazyInitializer->initializeObject($this);
|
||||
$this->__CG__initialized = true;
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
namespace CG\Tests\Proxy\Fixture;
|
||||
|
||||
/**
|
||||
* CG library enhanced proxy class.
|
||||
*
|
||||
* This code was generated automatically by the CG library, manual changes to it
|
||||
* will be lost upon next generation.
|
||||
*/
|
||||
class SimpleClass__CG__Enhanced extends \CG\Tests\Proxy\Fixture\SimpleClass implements \CG\Tests\Proxy\Fixture\MarkerInterface
|
||||
{
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
namespace CG\Tests\Proxy\Fixture;
|
||||
|
||||
/**
|
||||
* CG library enhanced proxy class.
|
||||
*
|
||||
* This code was generated automatically by the CG library, manual changes to it
|
||||
* will be lost upon next generation.
|
||||
*/
|
||||
class SimpleClass__CG__Sluggable extends \CG\Tests\Proxy\Fixture\SimpleClass implements \CG\Tests\Proxy\Fixture\SluggableInterface
|
||||
{
|
||||
public function getSlug()
|
||||
{
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user