Ejemplo n.º 1
0
 public function testRegisterToContainer()
 {
     $config = new TestPackage();
     $this->containerSvc->registerToContainer($config);
     $paths = $this->containerSvc->getEntityPaths();
     $this->assertContains('vendor/random/src/Entity', $paths);
     $this->assertEquals('A boring old string.', $this->containerSvc->getContainer()['test.package']);
 }
Ejemplo n.º 2
0
 public function testSetProxyPaths()
 {
     $this->containerSvc->setProxyPath('/path/to/proxies');
     // Initialise container
     $this->containerSvc->getContainer();
     $reflection = new ReflectionClass('Del\\Common\\ContainerService');
     $property = $reflection->getProperty('proxyPath');
     $property->setAccessible(true);
     $proxyPath = $property->getValue($this->containerSvc);
     $this->assertTrue(is_string($proxyPath));
     $this->assertEquals('/path/to/proxies', $proxyPath);
 }
Ejemplo n.º 3
0
 protected function _before()
 {
     $svc = ContainerService::getInstance();
     $config = new UserPackage();
     $svc->registerToContainer($config);
     $container = $svc->getContainer();
     $this->svc = $container['service.user'];
 }
Ejemplo n.º 4
0
 protected function _before()
 {
     $db = new DbCredentials();
     $package = new PersonPackage();
     $containerService = ContainerService::getInstance();
     $containerService->registerToContainer($db);
     $containerService->registerToContainer($package);
     $this->container = $containerService->getContainer();
 }
Ejemplo n.º 5
0
 protected function _before()
 {
     $creds = new DbCredentials();
     $creds->setDatabase('expenses');
     $package = new ExpensesPackage();
     ContainerService::getInstance()->registerToContainer($package);
     ContainerService::getInstance()->setDbCredentials($creds);
     $container = ContainerService::getInstance()->getContainer();
     $this->svc = $container['service.expenses'];
 }
Ejemplo n.º 6
0
 public function testAddToContainer()
 {
     ContainerService::getInstance()->registerToContainer($this->creds);
     $creds = ContainerService::getInstance()->getContainer()['db.credentials'];
     $this->assertTrue(is_array($creds));
     $this->assertArrayHasKey('driver', $creds);
     $this->assertArrayHasKey('dbname', $creds);
     $this->assertArrayHasKey('user', $creds);
     $this->assertArrayHasKey('password', $creds);
 }
Ejemplo n.º 7
0
 protected function _before()
 {
     $credentials = new DbCredentials();
     $container = ContainerService::getInstance()->setDbCredentials($credentials)->addEntityPath('src/Entity')->getContainer();
     $em = $container['doctrine.entity_manager'];
     $helperSet = ConsoleRunner::createHelperSet($em);
     $helperSet->set(new DialogHelper(), 'dialog');
     $this->app = new Application();
     $gen = new GenerateProxy();
     $gen->setHelperSet($helperSet);
     $this->app->add($gen);
     $this->app->add(new VersionCommand());
 }
Ejemplo n.º 8
0
 protected function _before()
 {
     $credentials = new DbCredentials();
     $container = ContainerService::getInstance()->setDbCredentials($credentials)->addEntityPath('src/Entity')->getContainer();
     $em = $container['doctrine.entity_manager'];
     $helperSet = ConsoleRunner::createHelperSet($em);
     $helperSet->set(new DialogHelper(), 'dialog');
     $configuration = new Configuration($em->getConnection());
     $configuration->setMigrationsNamespace('Migrations');
     $configuration->setMigrationsTableName('Migration');
     $this->app = new Application();
     $mig = new Migration();
     $mig->setMigrationConfiguration($configuration);
     $this->app->add($mig);
     $this->app->add(new VersionCommand());
 }
Ejemplo n.º 9
0
 public function init()
 {
     $this->container = ContainerService::getInstance()->getContainer();
 }
Ejemplo n.º 10
0
//$diff->setMigrationConfiguration($configuration);
//$exec->setMigrationConfiguration($configuration);
//$gen->setMigrationConfiguration($configuration);
//$migrate->setMigrationConfiguration($configuration);
//$status->setMigrationConfiguration($configuration);
//$ver->setMigrationConfiguration($configuration);
//
//$cli = ConsoleRunner::createApplication($helperSet,[
//    $diff, $exec, $gen, $migrate, $status, $ver
//]);
//
//return $cli->run();
use Del\Common\Command\Migration;
use Doctrine\DBAL\Migrations\Configuration\Configuration;
use Doctrine\DBAL\Migrations\Tools\Console\Command\DiffCommand;
use Doctrine\DBAL\Migrations\Tools\Console\Command\ExecuteCommand;
use Doctrine\DBAL\Migrations\Tools\Console\Command\GenerateCommand;
use Doctrine\DBAL\Migrations\Tools\Console\Command\MigrateCommand;
use Doctrine\DBAL\Migrations\Tools\Console\Command\StatusCommand;
use Doctrine\DBAL\Migrations\Tools\Console\Command\VersionCommand;
use Doctrine\ORM\Tools\Console\ConsoleRunner;
use Del\Common\ContainerService;
use Del\Common\Config\DbCredentials;
$credentials = new DbCredentials();
$container = ContainerService::getInstance()->setDbCredentials($credentials)->addEntityPath('src/Entity')->getContainer();
/** @var Doctrine\ORM\EntityManager $em*/
$em = $container['doctrine.entity_manager'];
$helperSet = ConsoleRunner::createHelperSet($em);
$helperSet->set(new \Symfony\Component\Console\Helper\DialogHelper(), 'dialog');
$cli = ConsoleRunner::createApplication($helperSet, []);
return $cli->run();
Ejemplo n.º 11
0
 /**
  * @return PimpleContainer
  */
 public static function getContainer()
 {
     return ContainerService::getInstance()->setDbCredentials(new DbCredentials())->addEntityPath('src/Entity')->getContainer();
 }