remove recess, bower, grunt and uglifyJs dependencies in php utils and tests

updated minifier tests
This commit is contained in:
Florian BLOUET
2015-12-02 17:16:47 +01:00
parent 82a35ce457
commit 261339ecd5
50 changed files with 19 additions and 993 deletions

View File

@@ -1,78 +0,0 @@
<?php
namespace Alchemy\Tests\Phrasea\Command\Developper;
use Alchemy\Phrasea\Command\Developer\BowerInstall;
/**
* @group functional
* @group legacy
*/
class BowerInstallTest extends \PhraseanetTestCase
{
public function testRunWithoutProblems()
{
$input = $this->getMock('Symfony\Component\Console\Input\InputInterface');
$output = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
self::$DI['cli']['filesystem'] = $this->getMockBuilder('Symfony\Component\Filesystem\Filesystem')
->disableOriginalConstructor()
->getMock();
self::$DI['cli']['driver.bower'] = $this->getMockBuilder('Alchemy\Phrasea\Command\Developer\Utils\BowerDriver')
->disableOriginalConstructor()
->getMock();
self::$DI['cli']['console'] = $this->getMockBuilder('Symfony\Component\Console\Application')
->disableOriginalConstructor()
->getMock();
$mockedCommand = $this->getMockBuilder('Symfony\Component\Console\Command\Command')
->setMethods(['execute'])
->disableOriginalConstructor()
->getMock();
self::$DI['cli']['console']->expects($this->any())
->method('get')
->will($this->returnValue($mockedCommand));
self::$DI['cli']['driver.grunt'] = $this->getMockBuilder('Alchemy\Phrasea\Command\Developer\Utils\GruntDriver')
->disableOriginalConstructor()
->getMock();
$processBuilder = $this->getMock('Alchemy\BinaryDriver\ProcessBuilderFactoryInterface');
$processBuilder->expects($this->any())
->method('getBinary');
self::$DI['cli']['driver.bower']->expects($this->at(0))
->method('getProcessBuilderFactory')
->will($this->returnValue($processBuilder));
self::$DI['cli']['driver.bower']->expects($this->at(1))
->method('command')
->with('-v')
->will($this->returnValue('1.0.0-alpha.5'));
self::$DI['cli']['driver.grunt']->expects($this->at(0))
->method('getProcessBuilderFactory')
->will($this->returnValue($processBuilder));
self::$DI['cli']['driver.grunt']->expects($this->at(1))
->method('getProcessBuilderFactory')
->will($this->returnValue($processBuilder));
self::$DI['cli']['driver.grunt']->expects($this->at(2))
->method('command')
->with('--version')
->will($this->returnValue('4.0.1'));
self::$DI['cli']['driver.grunt']->expects($this->at(3))
->method('command')
->with('install-assets');
$command = new BowerInstall();
$command->setContainer(self::$DI['cli']);
$this->assertEquals(0, $command->execute($input, $output));
}
}

View File

@@ -21,8 +21,7 @@ class InstallAllTest extends \PhraseanetTestCase
$n = 0;
foreach ([
'dependencies:composer',
'dependencies:bower'
'dependencies:composer'
] as $name) {
$command = $this->getMockBuilder('Symfony\Component\Console\Command\Command')
->setMethods(['execute'])

View File

@@ -1,30 +0,0 @@
<?php
namespace Alchemy\Tests\Phrasea\Command\Developper\Utils;
use Alchemy\Phrasea\Command\Developer\Utils\BowerDriver;
use Symfony\Component\Process\PhpExecutableFinder;
/**
* @group functional
* @group legacy
*/
class BowerDriverTest extends \PhraseanetTestCase
{
public function testCreate()
{
$driver = BowerDriver::create();
$this->assertInstanceOf('Alchemy\Phrasea\Command\Developer\Utils\BowerDriver', $driver);
$this->assertEquals('bower', $driver->getName());
}
public function testCreateWithCustomBinary()
{
$finder = new PhpExecutableFinder();
$php = $finder->find();
$driver = BowerDriver::create(['bower.binaries' => $php]);
$this->assertInstanceOf('Alchemy\Phrasea\Command\Developer\Utils\BowerDriver', $driver);
$this->assertEquals($php, $driver->getProcessBuilderFactory()->getBinary());
}
}

View File

@@ -1,33 +0,0 @@
<?php
namespace Alchemy\Tests\Phrasea\Command\Developper\Utils;
use Alchemy\Phrasea\Command\Developer\Utils\GruntDriver;
use Alchemy\Phrasea\Core\CLIProvider\CLIDriversServiceProvider;
use Symfony\Component\Process\PhpExecutableFinder;
/**
* @group functional
* @group legacy
*/
class GruntDriverTest extends \PhraseanetTestCase
{
public function testCreate()
{
$app = $this->getApplication();
$app->register(new CLIDriversServiceProvider());
$driver = GruntDriver::create(['grunt.binaries' => $app['driver.binary-finder']('grunt', 'grunt_binary')]);
$this->assertInstanceOf('Alchemy\Phrasea\Command\Developer\Utils\GruntDriver', $driver);
$this->assertEquals('grunt', $driver->getName());
}
public function testCreateWithCustomBinary()
{
$finder = new PhpExecutableFinder();
$php = $finder->find();
$driver = GruntDriver::create(['grunt.binaries' => $php]);
$this->assertInstanceOf('Alchemy\Phrasea\Command\Developer\Utils\GruntDriver', $driver);
$this->assertEquals($php, $driver->getProcessBuilderFactory()->getBinary());
}
}

View File

@@ -1,26 +0,0 @@
<?php
namespace Alchemy\Tests\Phrasea\Command\Developper\Utils;
use Alchemy\Phrasea\Command\Developer\Utils\RecessDriver;
/**
* @group functional
* @group legacy
*/
class RecessDriverTest extends \PhraseanetTestCase
{
public function testGetCreate()
{
$recessDriver = RecessDriver::create();
$this->assertInstanceOf('Alchemy\BinaryDriver\BinaryInterface', $recessDriver);
}
public function testGetName()
{
$recessDriver = RecessDriver::create();
$this->assertEquals('recess', $recessDriver->getName());
}
}

View File

@@ -1,33 +0,0 @@
<?php
namespace Alchemy\Tests\Phrasea\Command\Developper\Utils;
use Alchemy\Phrasea\Command\Developer\Utils\UglifyJsDriver;
use Alchemy\Phrasea\Core\CLIProvider\CLIDriversServiceProvider;
use Symfony\Component\Process\PhpExecutableFinder;
/**
* @group functional
* @group legacy
*/
class UglifyJsDriverTest extends \PhraseanetTestCase
{
public function testCreate()
{
$app = $this->getApplication();
$app->register(new CLIDriversServiceProvider());
$driver = UglifyJsDriver::create(['uglifyjs.binaries' => $app['driver.binary-finder']('uglifyjs', 'uglifyjs_binary')]);
$this->assertInstanceOf('Alchemy\Phrasea\Command\Developer\Utils\UglifyJsDriver', $driver);
$this->assertEquals('uglifyjs', $driver->getName());
}
public function testCreateWithCustomBinary()
{
$finder = new PhpExecutableFinder();
$php = $finder->find();
$driver = UglifyJsDriver::create(['uglifyjs.binaries' => $php]);
$this->assertInstanceOf('Alchemy\Phrasea\Command\Developer\Utils\UglifyJsDriver', $driver);
$this->assertEquals($php, $driver->getProcessBuilderFactory()->getBinary());
}
}

View File

@@ -5,6 +5,7 @@ namespace Alchemy\Tests\Phrasea\Controller;
/**
* @group functional
* @group legacy
* @group minify
*/
class MinifierTest extends \PhraseanetTestCase
{
@@ -25,23 +26,6 @@ class MinifierTest extends \PhraseanetTestCase
$_GET = [];
}
/**
* @dataProvider provideGroupsToMinify
*/
public function testGenerationOfGroups($name)
{
$_GET['g'] = $name;
self::$DI['client']->request('GET', '/include/minify/?g=' . $name);
$this->assertTrue(self::$DI['client']->getResponse()->isOk(), "Group $name is ok");
}
public function provideGroupsToMinify()
{
$groups = require __DIR__ . '/../../../../../lib/conf.d/minifyGroupsConfig.php';
return array_map(function ($group) {return [$group];}, array_keys($groups));
}
/**
* @dataProvider provideFilesToMinify
*/
@@ -54,17 +38,7 @@ class MinifierTest extends \PhraseanetTestCase
public function provideFilesToMinify()
{
$files = [];
$groups = require __DIR__ . '/../../../../../lib/conf.d/minifyGroupsConfig.php';
foreach ($groups as $name => $data) {
foreach ($data as $file) {
$files[] = substr($file, 2);
}
}
return array_map(function ($file) {return [$file];}, array_unique($files));
return [['scripts/apps/admin/require.config.js']];
}
public function testFileMinificationWithoutParamsShouldReturnA400()

View File

@@ -1,56 +0,0 @@
<?php
namespace Alchemy\Tests\Phrasea\Core\CLIProvider;
use Alchemy\Phrasea\CLI;
/**
* @group functional
* @group legacy
* @covers Alchemy\Phrasea\Core\CLIProvider\CLIDriversServiceProvider
*/
class CLISDriversServiceProviderTest extends ServiceProviderTestCase
{
public function provideServiceDescription()
{
return [
[
'Alchemy\Phrasea\Core\CLIProvider\CLIDriversServiceProvider',
'executable-finder',
'Symfony\Component\Process\ExecutableFinder'
],
[
'Alchemy\Phrasea\Core\CLIProvider\CLIDriversServiceProvider',
'driver.bower',
'Alchemy\Phrasea\Command\Developer\Utils\BowerDriver'
],
[
'Alchemy\Phrasea\Core\CLIProvider\CLIDriversServiceProvider',
'driver.composer',
'Alchemy\Phrasea\Command\Developer\Utils\ComposerDriver'
],
[
'Alchemy\Phrasea\Core\CLIProvider\CLIDriversServiceProvider',
'driver.uglifyjs',
'Alchemy\Phrasea\Command\Developer\Utils\UglifyJsDriver'
],
[
'Alchemy\Phrasea\Core\CLIProvider\CLIDriversServiceProvider',
'driver.recess',
'Alchemy\Phrasea\Command\Developer\Utils\RecessDriver'
],
];
}
public function testComposerTimeout()
{
$cli = new CLI('test');
$this->assertEquals(300, $cli['driver.composer']->getProcessBuilderFactory()->getTimeout());
}
public function testBowerTimeout()
{
$cli = new CLI('test');
$this->assertEquals(300, $cli['driver.bower']->getProcessBuilderFactory()->getTimeout());
}
}

View File

@@ -1,27 +0,0 @@
<?php
namespace Alchemy\Tests\Phrasea\Core\CLIProvider;
/**
* @group functional
* @group legacy
* @covers Alchemy\Phrasea\Core\CLIProvider\LessBuilderServiceProvider
*/
class LessBuilderServiceProviderTest extends ServiceProviderTestCase
{
public function provideServiceDescription()
{
return [
[
'Alchemy\Phrasea\Core\CLIProvider\LessBuilderServiceProvider',
'phraseanet.less-compiler',
'\Alchemy\Phrasea\Utilities\Less\Compiler'
],
[
'Alchemy\Phrasea\Core\CLIProvider\LessBuilderServiceProvider',
'phraseanet.less-builder',
'\Alchemy\Phrasea\Utilities\Less\Builder'
],
];
}
}

View File

@@ -53,7 +53,6 @@ main:
ffprobe_binary: null
mp4box_binary: null
pdftotext_binary: null
recess_binary: null
ffmpeg_timeout: 3600
ffprobe_timeout: 60
gs_timeout: 60

View File

@@ -67,7 +67,6 @@ main:
ffprobe_binary: null
mp4box_binary: null
pdftotext_binary: null
recess_binary: null
ffmpeg_timeout: 3600
ffprobe_timeout: 60
gs_timeout: 60

View File

@@ -53,7 +53,6 @@ main:
ffprobe_binary: null
mp4box_binary: null
pdftotext_binary: null
recess_binary: null
ffmpeg_timeout: 3600
ffprobe_timeout: 60
gs_timeout: 60

View File

@@ -1 +0,0 @@
@import "my-plugin/account.less";

View File

@@ -1 +0,0 @@
@import "my-plugin/login.less";

View File

@@ -0,0 +1 @@
@import "my-plugin/account.scss";

View File

@@ -0,0 +1 @@
@import "my-plugin/login.scss";

View File

@@ -1 +0,0 @@
@import "my-plugin/account.less";

View File

@@ -1 +0,0 @@
@import "my-plugin/login.less";

View File

@@ -0,0 +1 @@
@import "my-plugin/account.scss";

View File

@@ -0,0 +1 @@
@import "my-plugin/login.scss";

View File

@@ -25,8 +25,8 @@ class AutoloaderGeneratorTest extends \PhraseanetTestCase
$pluginsDir . '/autoload.php',
$pluginsDir . '/commands.php',
$pluginsDir . '/twig-paths.php',
$pluginsDir . '/login.less',
$pluginsDir . '/account.less',
$pluginsDir . '/login.scss',
$pluginsDir . '/account.scss',
];
$this->cleanup($files);
@@ -73,8 +73,8 @@ class AutoloaderGeneratorTest extends \PhraseanetTestCase
$mapping = require $pluginsDir . '/twig-paths.php';
$this->assertSame(['plugin-test-plugin' => realpath($pluginsDir) . '/test-plugin/views', realpath($pluginsDir) . '/test-plugin/views', realpath($pluginsDir) . '/test-plugin/twig-views'], $mapping);
$this->assertRegExp('#@import#', file_get_contents($pluginsDir . '/login.less'));
$this->assertRegExp('#@import#', file_get_contents($pluginsDir . '/account.less'));
$this->assertRegExp('#@import#', file_get_contents($pluginsDir . '/login.scss'));
$this->assertRegExp('#@import#', file_get_contents($pluginsDir . '/account.scss'));
$this->cleanup($files);
}

View File

@@ -1,27 +0,0 @@
<?php
namespace Alchemy\Tests\Phrasea\Utilities\Less;
use Alchemy\Phrasea\Utilities\Less\Builder;
/**
* @group functional
* @group legacy
*/
class BuilderTest extends \PhraseanetTestCase
{
public function testBuildSuccess()
{
$compiler = $this->getMockBuilder('Alchemy\Phrasea\Utilities\Less\Compiler')
->disableOriginalConstructor()
->getMock();
$compiler->expects($this->once())->method('compile');
$filesystem = $this->getMock('Symfony\Component\Filesystem\Filesystem');
$filesystem->expects($this->once())->method('mkdir');
$builder = new Builder($compiler, $filesystem);
$builder->build([ __FILE__ => __DIR__ . '/output.css']);
}
}

View File

@@ -1,66 +0,0 @@
<?php
namespace Alchemy\Tests\Phrasea\Utilities\Less;
use Alchemy\Phrasea\Utilities\Less\Compiler;
use Alchemy\BinaryDriver\Exception\ExecutionFailureException;
/**
* @group functional
* @group legacy
*/
class CompilerTest extends \PhraseanetTestCase
{
public function testCompileSuccess()
{
$recessDriver = $this->getMockBuilder('Alchemy\Phrasea\Command\Developer\Utils\RecessDriver')
->disableOriginalConstructor()
->getMock();
$recessDriver->expects($this->once())->method('command');
$filesystem = $this->getMock('Symfony\Component\Filesystem\Filesystem');
$filesystem->expects($this->once())->method('mkdir');
$filesystem->expects($this->once())->method('dumpFile');
$compiler = new Compiler($filesystem, $recessDriver);
$compiler->compile(__DIR__ . '/output.css', __FILE__);
}
/**
* @expectedException \Alchemy\Phrasea\Exception\RuntimeException
*/
public function testCompileFileNotExists()
{
$recessDriver = $this->getMockBuilder('Alchemy\Phrasea\Command\Developer\Utils\RecessDriver')
->disableOriginalConstructor()
->getMock();
$filesystem = $this->getMock('Symfony\Component\Filesystem\Filesystem');
$filesystem->expects($this->once())->method('mkdir');
$compiler = new Compiler($filesystem, $recessDriver);
$compiler->compile(__DIR__ . '/output.css', 'not_existsing_file');
}
/**
* @expectedException \Alchemy\Phrasea\Exception\RuntimeException
*/
public function testCompileExecutionFailure()
{
$recessDriver = $this->getMockBuilder('Alchemy\Phrasea\Command\Developer\Utils\RecessDriver')
->disableOriginalConstructor()
->getMock();
$recessDriver->expects($this->once())->method('command')->will(
$this->throwException(new ExecutionFailureException())
);
$filesystem = $this->getMock('Symfony\Component\Filesystem\Filesystem');
$compiler = new Compiler($filesystem, $recessDriver);
$compiler->compile(__DIR__ . '/output.css', __FILE__);
}
}