Skip to content

Commit

Permalink
Merge cystbear-rename-confusing-namespace into master
Browse files Browse the repository at this point in the history
  • Loading branch information
tshelburne committed Dec 14, 2014
2 parents 0b7c44e + 54f320d commit 6412094
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 25 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ $objects = $loader->load(__DIR__.'/fixtures.yml');
// optionally persist them into the doctrine object manager
// you can also do that yourself or persist them in another way
// if you do not use doctrine
$persister = new \Nelmio\Alice\ORM\Doctrine($objectManager);
$persister = new \Nelmio\Alice\Persister\Doctrine($objectManager);
$persister->persist($objects);
```

Expand Down
5 changes: 3 additions & 2 deletions src/Nelmio/Alice/Fixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Doctrine\Common\Persistence\ObjectManager;
use Psr\Log\LoggerInterface;
use Nelmio\Alice\Fixtures\Loader;
use Nelmio\Alice\Persister\Doctrine as DoctrinePersister;

class Fixtures
{
Expand Down Expand Up @@ -63,7 +64,7 @@ public function loadFiles($files, array $options = [])
$options = array_merge($this->defaultOptions, $options);

if ($this->container instanceof ObjectManager) {
$persister = new ORM\Doctrine($this->container);
$persister = new DoctrinePersister($this->container);
} else {
throw new \InvalidArgumentException('Unknown container type '.get_class($this->container));
}
Expand Down Expand Up @@ -92,7 +93,7 @@ public function loadFiles($files, array $options = [])
throw new \RuntimeException('Logger must be callable or an instance of Psr\Log\LoggerInterface.');
}

$loader->setORM($persister);
$loader->setPersister($persister);
$set = $loader->load($file);

if (!$options['persist_once']) {
Expand Down
12 changes: 6 additions & 6 deletions src/Nelmio/Alice/Fixtures/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Nelmio\Alice\Instances\Processor\Methods\Faker;
use Nelmio\Alice\Fixtures\ParameterBag;
use Psr\Log\LoggerInterface;
use Nelmio\Alice\ORMInterface;
use Nelmio\Alice\PersisterInterface;
use Nelmio\Alice\Instances\Collection;
use Nelmio\Alice\Instances\Instantiator;
use Nelmio\Alice\Instances\Populator;
Expand Down Expand Up @@ -63,7 +63,7 @@ class Loader
protected $populator;

/**
* @var ORMInterface
* @var PersisterInterface
*/
protected $manager;

Expand Down Expand Up @@ -313,14 +313,14 @@ protected function populateObjects(array $fixtures)
}

/**
* public interface to set the ORM interface
* public interface to set the Persister interface
*
* @param ORMInterface $manager
* @param PersisterInterface $manager
*/
public function setORM(ORMInterface $manager)
public function setPersister(PersisterInterface $manager)
{
$this->manager = $manager;
$this->typeHintChecker->setORM($manager);
$this->typeHintChecker->setPersister($manager);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
* file that was distributed with this source code.
*/

namespace Nelmio\Alice\ORM;
namespace Nelmio\Alice\Persister;

use Doctrine\Common\Persistence\ObjectManager;
use Nelmio\Alice\ORMInterface;
use Nelmio\Alice\PersisterInterface;

/**
* The Doctrine persists the fixtures into an ObjectManager
*/
class Doctrine implements ORMInterface
class Doctrine implements PersisterInterface
{
protected $om;
protected $flush;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Nelmio\Alice;

interface ORMInterface
interface PersisterInterface
{
/**
* Loads a fixture file
Expand Down
12 changes: 6 additions & 6 deletions src/Nelmio/Alice/Util/TypeHintChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@

namespace Nelmio\Alice\Util;

use Nelmio\Alice\ORMInterface;
use Nelmio\Alice\PersisterInterface;

class TypeHintChecker
{
/**
* ORMInterface
* PersisterInterface
*/
protected $manager;

/**
* public interface to set the ORM interface
* public interface to set the Persister interface
*
* @param ORMInterface $manager
* @param PersisterInterface $manager
*/
public function setORM(ORMInterface $manager)
public function setPersister(PersisterInterface $manager)
{
$this->manager = $manager;
}
Expand Down Expand Up @@ -70,7 +70,7 @@ public function check($obj, $method, $value, $pNum = 0)

if ($hintedClass) {
if (!$this->manager) {
throw new \LogicException('To reference objects by id you must first set a Nelmio\Alice\ORMInterface object on this instance');
throw new \LogicException('To reference objects by id you must first set a Nelmio\Alice\PersisterInterface object on this instance');
}
$value = $this->manager->find($hintedClass, $value);
}
Expand Down
8 changes: 4 additions & 4 deletions tests/Nelmio/Alice/Fixtures/LoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Nelmio\Alice\Fixtures;

use Nelmio\Alice\TestORM;
use Nelmio\Alice\TestPersister;
use Nelmio\Alice\support\models\User;
use Nelmio\Alice\support\extensions;

Expand All @@ -22,7 +22,7 @@ class LoaderTest extends \PHPUnit_Framework_TestCase
const GROUP = 'Nelmio\Alice\support\models\Group';
const CONTACT = 'Nelmio\Alice\support\models\Contact';

protected $orm;
protected $persister;

/**
* @var \Nelmio\Alice\Fixtures\Loader
Expand All @@ -33,7 +33,7 @@ protected function loadData(array $data, array $options = [])
{
$loader = $this->createLoader($options);

return $loader->load($data, $this->orm);
return $loader->load($data, $this->persister);
}

protected function createLoader(array $options = [])
Expand All @@ -46,7 +46,7 @@ protected function createLoader(array $options = [])
];
$options = array_merge($defaults, $options);

$this->orm = new TestORM;
$this->persister = new TestPersister;

return $this->loader = new Loader($options['locale'], $options['providers'], $options['seed'], $options['parameters']);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Nelmio/Alice/FixturesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class FixturesTest extends \PHPUnit_Framework_TestCase
const GROUP = 'Nelmio\Alice\support\models\Group';
const CONTACT = 'Nelmio\Alice\support\models\Contact';

public function testLoadLoadsYamlFilesAndDoctrineORM()
public function testLoadLoadsYamlFilesAndDoctrinePersister()
{
$om = $this->getDoctrineManagerMock(14);
$objects = Fixtures::load(__DIR__.'/support/fixtures/complete.yml', $om, ['providers' => [$this]]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Nelmio\Alice;

class TestORM implements ORMInterface
class TestPersister implements PersisterInterface
{
protected $objects;

Expand Down

0 comments on commit 6412094

Please sign in to comment.