Skip to content
This repository has been archived by the owner on Sep 15, 2022. It is now read-only.

Commit

Permalink
Merge pull request #160 from teohhanhui/patch-1
Browse files Browse the repository at this point in the history
Bump nelmio/alice to ~2.0
  • Loading branch information
Yann Rabiller committed Dec 2, 2015
2 parents fcd824b + ae20d4b commit b6bffcc
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 40 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"doctrine/data-fixtures": "~1.0",
"behat/mink-extension": "~2.0",
"fzaninotto/faker": "~1.0",
"nelmio/alice": "~1.7",
"nelmio/alice": "~2.0",
"guzzle/guzzle": "~3.7"
},
"require-dev": {
Expand Down
2 changes: 2 additions & 0 deletions doc/context-alice.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ Alice Context
=============
This context use the [nelmio/alice](https://github.com/nelmio/alice) fixture loading system.

>**Warning** : Alice context is compatible with nelmio/alice ~2.0.

Configuration
-------------
Expand Down
4 changes: 2 additions & 2 deletions spec/Knp/FriendlyContexts/Context/AliceContextSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ class AliceContextSpec extends ObjectBehavior
* @param \Doctrine\Common\Persistence\ManagerRegistry $doctrine
* @param \Doctrine\Common\Persistence\ObjectManager $manager
* @param \Behat\Behat\Hook\Scope\ScenarioScope $event
* @param Knp\FriendlyContexts\Alice\Fixtures\Loader $loader
* @param \Behat\Gherkin\Node\FeatureNode $feature
* @param \Behat\Gherkin\Node\ScenarioNode $scenario
* @param \Knp\FriendlyContexts\Alice\Loader\Yaml $loader
* @param \Doctrine\Common\Persistence\Mapping\ClassMetadataFactory $metadataFactory
* @param \Doctrine\Common\Persistence\Mapping\ClassMetadata $userMetadata
* @param \Doctrine\Common\Persistence\Mapping\ClassMetadata $placeMetadata
Expand All @@ -36,7 +36,7 @@ function let($container, $doctrine, $manager, $event, $loader, $feature, $scenar
$config = [ 'alice' => [ 'fixtures' => $fixtures, 'dependencies' => [] ]];
$container->has(Argument::any())->willReturn(true);
$container->hasParameter(Argument::any())->willReturn(true);
$container->get('friendly.alice.loader.yaml')->willReturn($loader);
$container->get('friendly.alice.fixtures.loader')->willReturn($loader);
$container->get('doctrine')->willReturn($doctrine);
$container->getParameter('friendly.alice.fixtures')->willReturn($fixtures);
$container->getParameter('friendly.alice.dependencies')->willReturn([]);
Expand Down
42 changes: 42 additions & 0 deletions src/Knp/FriendlyContexts/Alice/Fixtures/Loader.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace Knp\FriendlyContexts\Alice\Fixtures;

use Knp\FriendlyContexts\Alice\ProviderResolver;
use Nelmio\Alice\Fixtures\Loader as BaseLoader;

class Loader extends BaseLoader
{
private $cache = [];

public function __construct($locale, ProviderResolver $providers)
{
parent::__construct($locale, $providers->all());
}

public function getCache()
{
return $this->cache;
}

public function clearCache()
{
$this->cache = [];
}

/**
* {@inheritdoc}
*/
protected function instantiateFixtures(array $fixtures)
{
parent::instantiateFixtures($fixtures);

foreach ($fixtures as $fixture) {
$spec = array_map(function ($property) {
return $property->getValue();
}, $fixture->getProperties());

$this->cache[] = [ $spec, $this->objects->get($fixture->getName()) ];
}
}
}
34 changes: 0 additions & 34 deletions src/Knp/FriendlyContexts/Alice/Loader/Yaml.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/Knp/FriendlyContexts/Context/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected function getFeatureWalker()

protected function getAliceLoader()
{
return $this->get('friendly.alice.loader.yaml');
return $this->get('friendly.alice.fixtures.loader');
}

protected function getEntityManager()
Expand Down
4 changes: 2 additions & 2 deletions src/Knp/FriendlyContexts/services/core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ services:
- @service_container
- %friendly.alice.providers%

friendly.alice.loader.yaml:
class: Knp\FriendlyContexts\Alice\Loader\Yaml
friendly.alice.fixtures.loader:
class: Knp\FriendlyContexts\Alice\Fixtures\Loader
arguments:
- %friendly.alice.locale%
- @friendly.alice.provider_resolver
Expand Down

0 comments on commit b6bffcc

Please sign in to comment.