Skip to content

Commit

Permalink
refresh test (#1136)
Browse files Browse the repository at this point in the history
* refresh test

* add command tests

* use trait

* add use

* change backOffice to backoffice

* refresh tests

* refresh composer

* refresh composer
  • Loading branch information
veolys-nanne committed Jan 31, 2017
1 parent b91afea commit a94b1dc
Show file tree
Hide file tree
Showing 9 changed files with 248 additions and 78 deletions.
42 changes: 21 additions & 21 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

@@ -0,0 +1,51 @@
<?php

namespace OpenOrchestra\FunctionalTests\BackofficeBundle\Command;

use Symfony\Bundle\FrameworkBundle\Console\Application;
use OpenOrchestra\BackofficeBundle\Command\OrchestraPublishContentCommand;
use OpenOrchestra\BaseBundle\Tests\AbstractTest\AbstractWebTestCase;
use OpenOrchestra\FunctionalTests\BackofficeBundle\Command\PublishElementCommandTrait;

/**
* Class OrchestraPublishContentCommandTest
*/
class OrchestraPublishContentCommandTest extends AbstractWebTestCase
{
use PublishElementCommandTrait;

protected $application;

/**
* Set Up
*/
public function setUp()
{
$client = self::createClient();
$this->application = new Application($client->getKernel());
$this->application->setAutoExit(false);
$this->application->add(new OrchestraPublishContentCommand());
}

/**
* Test the command
*
* @param string $siteId
*
* @dataProvider provideSiteId
*/
public function testExecute($siteId)
{
$this->executePublish($siteId, 'orchestra:publish:content', 'open_orchestra_model.repository.content', 'content');
}

/**
* Provide site id
*/
public function provideSiteId()
{
return array(
array('2'),
);
}
}
@@ -1,17 +1,19 @@
<?php

namespace OpenOrchestra\FuntionalTests\BackOfficeBundle\Command;
namespace OpenOrchestra\FunctionalTests\BackofficeBundle\Command;

use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;
use OpenOrchestra\BaseBundle\Tests\AbstractTest\AbstractWebTestCase;
use OpenOrchestra\BackofficeBundle\Command\OrchestraPublishNodeCommand;
use OpenOrchestra\BaseBundle\Tests\AbstractTest\AbstractWebTestCase;
use OpenOrchestra\FunctionalTests\BackofficeBundle\Command\PublishElementCommandTrait;

/**
* Class OrchestraPublishNodeCommandTest
*/
class OrchestraPublishNodeCommandTest extends AbstractWebTestCase
{
use PublishElementCommandTrait;

protected $application;

/**
Expand All @@ -34,29 +36,7 @@ public function setUp()
*/
public function testExecute($siteId)
{
$command = $this->application->find('orchestra:publish:node');
$commandTester = new CommandTester($command);

$site = static::$kernel->getContainer()->get('open_orchestra_model.repository.site')->findOneBySiteId($siteId);
$fromStatus = static::$kernel->getContainer()->get('open_orchestra_model.repository.status')
->findByAutoPublishFrom();
$nodes = static::$kernel->getContainer()->get('open_orchestra_model.repository.node')
->findNodeToAutoPublish($site->getSiteId(), $fromStatus);

$commandTester->execute(array('command' => $command->getName()));
$this->assertRegExp(
'/Publishing nodes for siteId ' . $siteId . '/',
$commandTester->getDisplay()
);

foreach ($nodes as $node) {
$this->assertRegExp(
'/-> ' . $node->getName() . ' \(v' . $node->getVersion() . ' ' . $node->getLanguage() . '\) published/',
$commandTester->getDisplay()
);
}

$this->assertRegExp('/Done./', $commandTester->getDisplay());
$this->executePublish($siteId, 'orchestra:publish:node', 'open_orchestra_model.repository.node', 'node');
}

/**
Expand Down
@@ -0,0 +1,51 @@
<?php

namespace OpenOrchestra\FunctionalTests\BackofficeBundle\Command;

use OpenOrchestra\BackofficeBundle\Command\OrchestraUnpublishContentCommand;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use OpenOrchestra\BaseBundle\Tests\AbstractTest\AbstractWebTestCase;
use OpenOrchestra\FunctionalTests\BackofficeBundle\Command\PublishElementCommandTrait;

/**
* Class OrchestraUnpublishContentCommandTest
*/
class OrchestraUnpublishContentCommandTest extends AbstractWebTestCase
{
use PublishElementCommandTrait;

protected $application;

/**
* Set Up
*/
public function setUp()
{
$client = self::createClient();
$this->application = new Application($client->getKernel());
$this->application->setAutoExit(false);
$this->application->add(new OrchestraUnpublishContentCommand());
}

/**
* Test the command
*
* @param string $siteId
*
* @dataProvider provideSiteId
*/
public function testExecute($siteId)
{
$this->executeUnpublish($siteId, 'orchestra:unpublish:content', 'open_orchestra_model.repository.content', 'content');
}

/**
* Provide site id
*/
public function provideSiteId()
{
return array(
array('2'),
);
}
}
@@ -1,17 +1,19 @@
<?php

namespace OpenOrchestra\FuntionalTests\BackOfficeBundle\Command;
namespace OpenOrchestra\FunctionalTests\BackofficeBundle\Command;

use OpenOrchestra\BackofficeBundle\Command\OrchestraUnpublishNodeCommand;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;
use OpenOrchestra\BaseBundle\Tests\AbstractTest\AbstractWebTestCase;
use OpenOrchestra\FunctionalTests\BackofficeBundle\Command\PublishElementCommandTrait;

/**
* Class OrchestraUnpublishNodeCommandTest
*/
class OrchestraUnpublishNodeCommandTest extends AbstractWebTestCase
{
use PublishElementCommandTrait;

protected $application;

/**
Expand All @@ -34,29 +36,7 @@ public function setUp()
*/
public function testExecute($siteId)
{
$command = $this->application->find('orchestra:unpublish:node');
$commandTester = new CommandTester($command);

$site = static::$kernel->getContainer()->get('open_orchestra_model.repository.site')->findOneBySiteId($siteId);
$publishedStatus = static::$kernel->getContainer()->get('open_orchestra_model.repository.status')
->findOneByPublished();
$nodes = static::$kernel->getContainer()->get('open_orchestra_model.repository.node')
->findNodeToAutoUnpublish($site->getSiteId(), $publishedStatus);

$commandTester->execute(array('command' => $command->getName()));
$this->assertRegExp(
'/Unpublishing nodes for siteId ' . $siteId . '/',
$commandTester->getDisplay()
);

foreach ($nodes as $node) {
$this->assertRegExp(
'/-> ' . $node->getName(). ' \(v' . $node->getVersion() . ' ' . $node->getLanguage() . '\) unpublished/',
$commandTester->getDisplay()
);
}

$this->assertRegExp('/Done./', $commandTester->getDisplay());
$this->executeUnpublish($siteId, 'orchestra:unpublish:node', 'open_orchestra_model.repository.node', 'node');
}

/**
Expand Down

0 comments on commit a94b1dc

Please sign in to comment.