mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
add initial tests.
This commit is contained in:
parent
04831e062f
commit
c9b8b3be9a
5 changed files with 115 additions and 2 deletions
|
|
@ -36,7 +36,7 @@ class Configuration implements ConfigurationInterface
|
|||
$rootNode
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('storage')->defaultValue('sylius_flow.storage.session')->end()
|
||||
->scalarNode('storage')->defaultValue('sylius_flow.storage.session')->cannotBeEmpty()->end()
|
||||
->end()
|
||||
;
|
||||
|
||||
|
|
|
|||
|
|
@ -174,6 +174,10 @@ class Process implements ProcessInterface
|
|||
throw new \InvalidArgumentException(sprintf('Step with name "%s" already exists', $name));
|
||||
}
|
||||
|
||||
if (null === $step->getName()) {
|
||||
$step->setName($name);
|
||||
}
|
||||
|
||||
$this->steps[$name] = $this->orderedSteps[] = $step;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\FlowBundle\Tests\DependencyInjection;
|
||||
|
||||
use Sylius\Bundle\FlowBundle\DependencyInjection\SyliusFlowExtension;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\Yaml\Parser;
|
||||
|
||||
/**
|
||||
* Dependency injection extension test.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
class SyliusFlowExtensionTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
|
||||
*/
|
||||
public function shouldThrowExceptionUnlessStorageConfigured()
|
||||
{
|
||||
$extension = new SyliusFlowExtension();
|
||||
|
||||
$config = $this->getEmptyConfig();
|
||||
$config['storage'] = '';
|
||||
|
||||
$extension->load(array($config), new ContainerBuilder());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get empty config for testing.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getEmptyConfig()
|
||||
{
|
||||
$yaml =
|
||||
<<<EOF
|
||||
storage: sylius_flow.storage.session
|
||||
EOF;
|
||||
|
||||
$parser = new Parser();
|
||||
|
||||
return $parser->parse($yaml);
|
||||
}
|
||||
}
|
||||
54
src/Sylius/Bundle/FlowBundle/Tests/Process/ProcessTest.php
Normal file
54
src/Sylius/Bundle/FlowBundle/Tests/Process/ProcessTest.php
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\FlowBundle\Tests\Process;
|
||||
|
||||
use Sylius\Bundle\FlowBundle\Process\Context\ProcessContextInterface;
|
||||
use Sylius\Bundle\FlowBundle\Process\Process;
|
||||
use Sylius\Bundle\FlowBundle\Process\Step\Step;
|
||||
|
||||
/**
|
||||
* Process test.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
class ProcessTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function shouldKeepStepsInOrderWhileAddingSteps()
|
||||
{
|
||||
$process = new Process();
|
||||
|
||||
$process->addStep('foo', new TestStep());
|
||||
$process->addStep('bar', new TestStep());
|
||||
$process->addStep('foobar', new TestStep());
|
||||
|
||||
$correctOrder = array('foo', 'bar', 'foobar');
|
||||
|
||||
foreach ($process->getOrderedSteps() as $i => $step) {
|
||||
$this->assertSame($correctOrder[$i], $step->getName());
|
||||
}
|
||||
|
||||
foreach ($correctOrder as $i => $name) {
|
||||
$this->assertSame($name, $process->getStepByIndex($i)->getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TestStep extends Step
|
||||
{
|
||||
public function displayAction(ProcessContextInterface $context)
|
||||
{
|
||||
// pufff.
|
||||
}
|
||||
}
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
if (!file_exists($file = __DIR__.'/../vendor/.composer/autoload.php')) {
|
||||
if (!file_exists($file = __DIR__.'/../vendor/autoload.php')) {
|
||||
die("Please install dependencies using Composer to run the test suite. \n");
|
||||
} else {
|
||||
require_once $file;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue