Skip to content

Commit

Permalink
Merge branch 'feature/optionnal-config' - fixes #86
Browse files Browse the repository at this point in the history
  • Loading branch information
Ocramius committed Sep 13, 2013
2 parents 44da164 + 5ffb429 commit f4f8ed9
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ProxyManager/Factory/AbstractBaseFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ abstract class AbstractBaseFactory
/**
* @param \ProxyManager\Configuration $configuration
*/
public function __construct(Configuration $configuration)
public function __construct(Configuration $configuration = null)
{
$this->configuration = $configuration;
$this->configuration = $configuration ?: new Configuration();
// localizing some properties for performance
$this->autoGenerate = $this->configuration->doesAutoGenerateProxies();
$this->inflector = $this->configuration->getClassNameInflector();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ public function setUp()
->will($this->returnValue($this->inflector));
}

/**
* {@inheritDoc}
*
* @covers \ProxyManager\Factory\AccessInterceptorValueHolderFactory::__construct
*/
public function testWithOptionalFactory()
{
$factory = new AccessInterceptorValueHolderFactory();
$this->assertAttributeNotEmpty('configuration', $factory);
$this->assertAttributeInstanceOf('ProxyManager\Configuration', 'configuration', $factory);
}

/**
* {@inheritDoc}
*
Expand Down
13 changes: 13 additions & 0 deletions tests/ProxyManagerTest/Factory/LazyLoadingGhostFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use PHPUnit_Framework_TestCase;
use ProxyManager\Factory\LazyLoadingGhostFactory;
use ProxyManager\Generator\ClassGenerator;
use \ProxyManager\Configuration;
use ProxyManager\Generator\Util\UniqueIdentifierGenerator;

/**
Expand Down Expand Up @@ -54,6 +55,18 @@ public function setUp()
->method('getClassNameInflector')
->will($this->returnValue($this->inflector));
}

/**
* {@inheritDoc}
*
* @covers \ProxyManager\Factory\LazyLoadingGhostFactory::__construct
*/
public function testWithOptionalFactory()
{
$factory = new LazyLoadingGhostFactory();
$this->assertAttributeNotEmpty('configuration', $factory);
$this->assertAttributeInstanceOf('ProxyManager\Configuration', 'configuration', $factory);
}

/**
* {@inheritDoc}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@ public function setUp()
->will($this->returnValue($this->inflector));
}

/**
* {@inheritDoc}
*
* @covers \ProxyManager\Factory\LazyLoadingValueHolderFactory::__construct
*/
public function testWithOptionalFactory()
{
$factory = new LazyLoadingValueHolderFactory();
$this->assertAttributeNotEmpty('configuration', $factory);
$this->assertAttributeInstanceOf('ProxyManager\Configuration', 'configuration', $factory);
}

/**
* {@inheritDoc}
*
Expand Down

0 comments on commit f4f8ed9

Please sign in to comment.