Refactor command line utilities

This commit is contained in:
Romain Neutron
2013-07-16 16:01:17 +02:00
parent 86e108b20f
commit 056ac28120
59 changed files with 1031 additions and 592 deletions

View File

@@ -1,5 +1,6 @@
<?php
use Alchemy\Phrasea\CLI;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Border\File;
use Doctrine\Common\DataFixtures\Loader;
@@ -154,6 +155,48 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
return $app;
});
self::$DI['cli'] = self::$DI->share(function($DI) use ($phpunit) {
$app = new CLI('cli test', null, 'test');
$app['form.csrf_provider'] = $app->share(function () {
return new CsrfTestProvider();
});
$app['url_generator'] = $app->share($app->extend('url_generator', function($generator, $app) {
$host = parse_url($app['phraseanet.configuration']['main']['servername'], PHP_URL_HOST);
$generator->setContext(new RequestContext('', 'GET', $host));
return $generator;
}));
$app['debug'] = true;
$app['EM'] = $app->share($app->extend('EM', function($em) {
@unlink('/tmp/db.sqlite');
copy(__DIR__ . '/../db-ref.sqlite', '/tmp/db.sqlite');
return $em;
}));
$app['browser'] = $app->share($app->extend('browser', function($browser) {
$browser->setUserAgent(PhraseanetPHPUnitAbstract::USER_AGENT_FIREFOX8MAC);
return $browser;
}));
$app['notification.deliverer'] = $phpunit->getMockBuilder('Alchemy\Phrasea\Notification\Deliverer')
->disableOriginalConstructor()
->getMock();
$app['notification.deliverer']->expects($phpunit->any())
->method('deliver')
->will($phpunit->returnCallback(function() use ($phpunit) {
$phpunit->fail('Notification deliverer must be mocked');
}));
return $app;
});
self::$DI['client'] = self::$DI->share(function($DI) {
return new Client($DI['app'], array());
});