Skip to content

Commit

Permalink
fixed assets install tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kilip committed Oct 31, 2018
1 parent 1959330 commit afb92d4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
20 changes: 4 additions & 16 deletions module/Core/src/Controller/Console/AssetsInstallController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Output\StreamOutput;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;
use Zend\ModuleManager\ModuleManager;
use Zend\Mvc\Console\Controller\AbstractConsoleController;
use Zend\View\Stream;

/**
* Class AssetsInstallController
Expand Down Expand Up @@ -64,24 +62,11 @@ public function __construct(array $modules = [])

public static function factory(ContainerInterface $container)
{
static $stream;

/* @var ModuleManager $manager */
$manager = $container->get('ModuleManager');

$modules = $manager->getLoadedModules();
$config = $container->get('ApplicationConfig');
$ob = new static($modules);

if ($config['environment'] === 'test') {
if (is_null($stream)) {
$stream = fopen('php://memory', 'w');
}
$ob->setOutput(new StreamOutput(
$stream
));
}
return $ob;
return new static($modules);
}

/**
Expand All @@ -104,6 +89,9 @@ public function setOutput($output)
return $this;
}

/**
* @return ConsoleOutput|OutputInterface
*/
public function getOutput()
{
return $this->output;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,35 @@

use Core\Controller\Console\AssetsInstallController;
use CoreTest\Bootstrap;
use Interop\Container\ContainerInterface;
use Symfony\Component\Console\Output\StreamOutput;
use Symfony\Component\Console\Tester\CommandTester;
use Zend\Stdlib\ArrayUtils;
use Zend\Test\PHPUnit\Controller\AbstractConsoleControllerTestCase;

class AssetsInstallControllerTest extends AbstractConsoleControllerTestCase
{
/**
* @var AssetsInstallController
*/
private $controller;

/**
* @var StreamOutput
*/
private $output;

public function setUp()
{
$this->setApplicationConfig(Bootstrap::getConfig());
parent::setUp();
$this->setUseConsoleRequest(true);

$output = new StreamOutput(
fopen('php://memory', 'w')
);
$manager = $this->getApplicationServiceLocator()->get('ControllerManager');
$controller = $manager->get(AssetsInstallController::class);
$controller->setOutput($output);
$this->output = $output;
$this->controller = $controller;
}

public function testSymlink()
Expand Down Expand Up @@ -79,9 +93,7 @@ public function testCopy()
*/
public function getDisplay($normalize = false)
{
$sm = $this->getApplicationServiceLocator();
$controller = $sm->get(AssetsInstallController::class);
$output = $controller->getOutput();
$output = $this->output;

rewind($output->getStream());

Expand Down

0 comments on commit afb92d4

Please sign in to comment.