public function testDatabaseConnection()
 {
     $container = new Container();
     $container->register(new DatabaseServiceProvider());
     $container->instance('viserio.database.options', ['default' => 'sqlite', 'connections' => ['sqlite' => ['driver' => 'pdo_sqlite', 'database' => __DIR__ . '/../Stub/database.sqlite', 'memory' => true]]]);
     $conn = $container->get(Connection::class);
     $sql = 'SELECT name FROM text WHERE id = 1';
     $collection = $conn->fetchArray($sql);
     $this->assertInstanceOf(Collection::class, $collection);
     $this->assertSame([0 => 'narrowspark'], $collection->all());
     $collection = $conn->fetchAll($sql);
     $this->assertInstanceOf(Collection::class, $collection);
     $this->assertSame(['name' => 'narrowspark'], $collection->all());
     $collection = $conn->fetchAssoc($sql);
     $this->assertInstanceOf(Collection::class, $collection);
     $this->assertSame(['name' => 'narrowspark'], $collection->all());
     $stmt = $conn->prepare($sql);
     $stmt->execute();
     $collection = $stmt->fetchAll();
     $this->assertInstanceOf(Collection::class, $collection);
     $this->assertSame(['name' => 'narrowspark'], $collection->all());
     $stmt = $conn->query($sql);
     $collection = $stmt->fetch();
     $this->assertInstanceOf(Collection::class, $collection);
     $this->assertSame(['name' => 'narrowspark'], $collection->all());
     $stmt = $conn->query('SELECT name FROM text WHERE id = 2');
     $this->assertFalse($stmt->fetch());
 }
 public function testProviderWithoutConfigManagerAndNamespace()
 {
     $container = new Container();
     $container->register(new EventsServiceProvider());
     $container->register(new ConsoleServiceProvider());
     $container->instance('viserio.console.options', ['version' => '1']);
     $this->assertInstanceOf(Application::class, $container->get(Application::class));
 }
 public function testProviderWithoutConfigManagerAndNamespace()
 {
     $container = new Container();
     $container->register(new HashingServiceProvider());
     $container->instance('viserio.hashing.options', ['key' => Key::createNewRandomKey()]);
     $this->assertInstanceOf(Password::class, $container->get(Password::class));
     $this->assertInstanceOf(Password::class, $container->get('password'));
 }
 public function testProvider()
 {
     $container = new Container();
     $container->register(new PipelineServiceProvider());
     $this->assertInstanceOf(Pipeline::class, $container->get(Pipeline::class));
     $this->assertInstanceOf(Pipeline::class, $container->get(PipelineContract::class));
     $this->assertInstanceOf(Pipeline::class, $container->get('pipeline'));
 }
 public function testProvider()
 {
     $container = new Container();
     $container->register(new RoutingServiceProvider());
     $container->register(new EventsServiceProvider());
     $this->assertInstanceOf(Router::class, $container->get(Router::class));
     $this->assertInstanceOf(Router::class, $container->get('router'));
 }
예제 #6
0
 public function testProviderWithoutConfigManagerAndNamespace()
 {
     $container = new Container();
     $container->register(new CookieServiceProvider());
     $container->instance('viserio.cookie.options', ['domain' => '', 'path' => '', 'secure' => true]);
     $this->assertInstanceOf(RequestCookie::class, $container->get(RequestCookie::class));
     $this->assertInstanceOf(CookieJar::class, $container->get(CookieJar::class));
 }
 public function testProvider()
 {
     $container = new Container();
     $container->register(new FilesServiceProvider());
     $this->assertInstanceOf(Filesystem::class, $container->get(Filesystem::class));
     $this->assertInstanceOf(Filesystem::class, $container->get(FilesystemContract::class));
     $this->assertInstanceOf(Filesystem::class, $container->get('files'));
 }
 public function testProviderWithoutConfigManagerAndNamespace()
 {
     $container = new Container();
     $container->register(new DatabaseServiceProvider());
     $container->register(new MigrationsServiceProvider());
     $container->instance('viserio.database.options', ['default' => 'sqlite', 'connections' => ['mysql' => ['driver' => 'pdo_mysql', 'host' => 'DB_HOST', 'port' => 'DB_PORT', 'database' => 'DB_DATABASE_NAME', 'username' => 'DB_DATABASE_USER', 'password' => 'DB_DATABASE_PASSWORD', 'charset' => 'DB_CHARSET', 'UTF8', 'driverOptions' => [1002 => 'SET NAMES utf8']], 'sqlite' => ['driver' => 'pdo_sqlite', 'username' => 'DB_DATABASE_USER', 'database' => __DIR__ . '/../Stub/database.sqlite', 'memory' => true]], 'migrations' => ['path' => env('DB_MIGRATION_PATH', __DIR__ . '/../Stub/'), 'namespace' => 'Database\\Migrations', 'name' => 'migration', 'table_name' => 'migration']]);
     $this->assertTrue(is_array($container->get('migrations.commands')));
 }
 public function testProviderWithoutConfigManagerAndNamespace()
 {
     $container = new Container();
     $container->register(new ParsersServiceProvider());
     $container->register(new TranslatorServiceProvider());
     $container->instance('viserio.translation.options', ['locale' => 'en', 'lang_path' => $this->file->url()]);
     $this->assertInstanceOf(TranslationManager::class, $container->get(TranslationManager::class));
 }
 public function testProviderWithoutConfigManagerAndNamespace()
 {
     $container = new Container();
     $container->register(new EncrypterServiceProvider());
     $key = Key::createNewRandomKey();
     $container->instance('viserio.encryption.options', ['key' => $key->saveToAsciiSafeString()]);
     $this->assertInstanceOf(Encrypter::class, $container->get(Encrypter::class));
     $this->assertInstanceOf(Encrypter::class, $container->get('encrypter'));
 }
예제 #11
0
 public function testProvider()
 {
     $container = new Container();
     $container->register(new FilesServiceProvider());
     $container->register(new ViewServiceProvider());
     $container->instance(ServerRequestInterface::class, $this->mock(ServerRequestInterface::class));
     $this->assertInstanceOf(Factory::class, $container->get(Factory::class));
     $this->assertInstanceOf(Factory::class, $container->get('view'));
     $this->assertInstanceOf(ViewFinder::class, $container->get('view.finder'));
     $this->assertInstanceOf(ViewFinder::class, $container->get(ViewFinder::class));
     $this->assertInstanceOf(EngineResolver::class, $container->get('view.engine.resolver'));
     $this->assertInstanceOf(EngineResolver::class, $container->get(EngineResolver::class));
 }
예제 #12
0
 public function testProvider()
 {
     $container = new Container();
     $container->register(new EncrypterServiceProvider());
     $container->register(new ConfigServiceProvider());
     $container->register(new SessionServiceProvider());
     $container->register(new FilesServiceProvider());
     $key = Key::createNewRandomKey();
     $container->get('config')->set('encryption', ['key' => $key->saveToAsciiSafeString()]);
     $container->get('config')->set('session', ['path' => '', 'lifetime' => 3000, 'cookie' => 'test']);
     $this->assertInstanceOf(SessionManager::class, $container->get(SessionManager::class));
     $this->assertInstanceOf(SessionManager::class, $container->get('session'));
     $this->assertInstanceOf(StoreContract::class, $container->get('session.store'));
 }
예제 #13
0
 public function testProviderWithoutConfigManagerAndNamespace()
 {
     $container = new Container();
     $container->register(new LoggerServiceProvider());
     $container->register(new EventsServiceProvider());
     $container->instance('viserio.log.options', ['env' => 'dev']);
     $this->assertInstanceOf(MonologWriter::class, $container->get(LoggerInterface::class));
     $this->assertInstanceOf(MonologWriter::class, $container->get(MonologWriter::class));
     $this->assertInstanceOf(MonologWriter::class, $container->get(Logger::class));
     $this->assertInstanceOf(MonologWriter::class, $container->get(Log::class));
     $this->assertInstanceOf(DispatcherContract::class, $container->get('logger')->getEventsDispatcher());
 }
예제 #14
0
 /**
  * {@inheritdoc}
  */
 public function has($id)
 {
     if (isset($this->mockedServices['mock::' . $this->normalize($this->normalize($id))])) {
         return true;
     }
     return parent::has($id);
 }
예제 #15
0
 /**
  * Create a new application instance.
  *
  * Let's start make magic!
  *
  * @param array $paths
  */
 public function __construct(array $paths)
 {
     parent::__construct();
     /*
      * Here we are binding the paths configured in paths.php to the app. You
      * should not be changing these here. If you need to change these you
      * may do so within the paths.php file and they will be bound here.
      */
     $this->registerBaseServiceProviders();
     $this->bindInstallPaths($paths);
     $this->registerCacheFilePaths();
     $this->registerBaseBindings();
 }
 public function testProviderWithoutConfigManagerAndNamespace()
 {
     $container = new Container();
     $container->register(new ExceptionServiceProvider());
     $container->register(new ViewServiceProvider());
     $container->register(new FilesServiceProvider());
     $container->instance('viserio.exception.options', ['debug' => true]);
     $this->assertInstanceOf(VerboseFilter::class, $container->get(VerboseFilter::class));
 }
예제 #17
0
 public function testProvider()
 {
     $container = new Container();
     $container->register(new CacheServiceProvider());
     $container->register(new ConfigServiceProvider());
     $this->assertInstanceOf(CacheManager::class, $container->get(CacheManager::class));
     $this->assertInstanceOf(CacheManager::class, $container->get('cache'));
     $this->assertInstanceOf(ArrayCachePool::class, $container->get('cache.store'));
 }
예제 #18
0
 public function testProvider()
 {
     $container = new Container();
     $container->register(new ConfigServiceProvider());
     $config = $container->get(ConfigManager::class);
     $config->set('foo', 'bar');
     $alias = $container->get('config');
     $this->assertInstanceOf(Repository::class, $container->get(Repository::class));
     $this->assertInstanceOf(ConfigManager::class, $config);
     $this->assertInstanceOf(ConfigManager::class, $container->get(ManagerContract::class));
     $this->assertEquals($config, $alias);
     $this->assertTrue($config->has('foo'));
     $this->assertTrue($alias->has('foo'));
     $this->assertSame('bar', $config->get('foo'));
 }
예제 #19
0
 public function testExtendingNothing()
 {
     $container = new Container();
     $container->register(new SimpleFixtureServiceProvider());
     $this->assertNull($container->get('previous'));
 }
예제 #20
0
 public function testExtendedBindingsKeptTypes()
 {
     $container = new Container();
     $container->singleton(['foo' => 'foo2'], function () {
         return (object) ['name' => 'narrowspark'];
     });
     $container->extend('foo', function ($old, $container) {
         $old->oldName = 'viserio';
         return $old;
     });
     $container->bind('bar', function () {
         return (object) ['name' => 'narrowspark'];
     });
     $container->extend('bar', function ($old, $container) {
         $old->oldName = 'viserio';
         return $old;
     });
     $this->assertSame($container->make('foo'), $container->make('foo'));
     $this->assertSame($container->make('foo'), $container->make('foo2'));
     $this->assertNotSame($container->make('bar'), $container->make('bar'));
 }
예제 #21
0
 public function testProvider()
 {
     $container = new Container();
     $container->register(new EventsServiceProvider());
     $this->assertInstanceOf(Dispatcher::class, $container->get(Dispatcher::class));
 }
 public function testProvider()
 {
     $container = new Container();
     $container->register(new ConfigServiceProvider());
     $container->register(new FilesystemServiceProvider());
     $container->register(new CacheServiceProvider());
     $container->get('config')->setArray(['filesystem.connections' => ['local' => ['path' => __DIR__, 'prefix' => 'your-prefix']]]);
     $this->assertInstanceOf(FilesystemManager::class, $container->get(FilesystemManager::class));
     $this->assertInstanceOf(FilesystemManager::class, $container->get(Filesystem::class));
     $this->assertInstanceOf(FilesystemManager::class, $container->get(FilesystemInterface::class));
     $this->assertInstanceOf(FilesystemManager::class, $container->get('flysystem'));
     $this->assertInstanceOf(FilesystemAdapter::class, $container->get('flysystem.connection'));
     $this->assertInstanceOf(CachedFactory::class, $container->get(CachedFactory::class));
     $this->assertInstanceOf(CachedFactory::class, $container->get('flysystem.cachedfactory'));
     $this->assertInstanceOf(FilesystemManager::class, $container->get(FilesystemManager::class));
     $this->assertInstanceOf(CachedFactory::class, $container->get(CachedFactory::class));
 }