public function setup() { $container = new \Nette\DI\Container; $container->params = array('productionMode' => FALSE, 'appDir' => __DIR__ . "/.."); $container->addService('entityManager', \Doctrine\Tests\Mocks\EntityManagerMock::create( new \Doctrine\DBAL\Connection(array(), new \Doctrine\DBAL\Driver\PDOSqlite\Driver) )); $container = new \Nella\Doctrine\Container($container); $this->service = new Service($container, 'NellaTests\Doctrine\Service\EntityMock'); }
public function setup() { parent::setup(); $container = new \Nette\DI\Container; $container->params = array('productionMode' => FALSE, 'appDir' => __DIR__ . "/.."); $container->addService('migrationConfiguration', new \Doctrine\DBAL\Migrations\Configuration\Configuration( new \Doctrine\DBAL\Connection(array(), new \Doctrine\DBAL\Driver\PDOSqlite\Driver) )); $container = new \Nella\Doctrine\Container($container); $this->helper = new \Nella\Doctrine\MigrationConfigurationHelper($container); }
<?php require_once __DIR__ . '/bootstrap.php'; $container = new \Nette\DI\Container(); $container->addService('foo', new stdClass()); dump($container->getService('foo')); $container->parameters['bar'] = TRUE; dump($container->parameters);
'storageDir' => "%tempDir", 'imageCacheDir' => "%tempDir", 'productionMode' => FALSE, 'consoleMode' => TRUE, 'flashes' => array( 'success' => "success", 'error' => "error", 'info' => "info", 'warning' => "warning", ), 'database' => array( 'driver' => "pdo_mysql", 'memory' => TRUE, ), ); $container->addService('cacheStorage', 'Nette\Caching\Storages\DevNullStorage'); $container->addService('templateCacheStorage', function(Nette\DI\Container $container) { return $container->cacheStorage; }); $container->addService('user', 'NellaTests\Mocks\User'); $container->addService('httpRequest', function() { $factory = new Nette\Http\RequestFactory; $factory->setEncoding('UTF-8'); return $factory->createHttpRequest(); }); $container->addService('httpResponse', 'Nette\Http\Response'); $container->addService('components', 'Nella\Application\UI\ComponentContainer'); $container->addService('macros', 'Nella\Latte\Macros'); $container->addService('model', function() { $context = new \Nella\Doctrine\Container; $context->addService('entityManager', \Doctrine\Tests\Mocks\EntityManagerMock::create(
<?php $container = new Nette\DI\Container(); class MyService { function method1($a, $b, $c) { file_put_contents(TEMP_DIR . '/method1.called.txt', serialize(func_get_args())); } static function method2($a, $b, $c) { file_put_contents(TEMP_DIR . '/method2.called.txt', serialize(func_get_args())); } static function method3($a, $b, $c) { throw new Exception('FAIL!'); } } $myService = new MyService(); $container->addService('myService', $myService); return $container;