示例#1
0
 public function testLifecycle()
 {
     $key = static::class;
     $this->assertNull(Container::get($key));
     Container::set($key, $this);
     $this->assertEquals($this, Container::get($key));
 }
示例#2
0
 /**
  * Constructor
  *
  * @param   Request         $request
  * @param   RequestParser   $requestParser
  * @param   Response        $response
  * @param   ResponseWriter  $responseWriter
  * @param   Pipeline        $pipeline
  */
 public function __construct(Request $request = null, RequestParser $requestParser = null, Response $response = null, ResponseWriter $responseWriter = null, Pipeline $pipeline = null)
 {
     $this->request = $request;
     $this->requestParser = $requestParser ?? Container::get('RequestParser');
     $this->response = $response;
     $this->responseWriter = $responseWriter ?? Container::get('ResponseWriter');
     $this->pipeline = $pipeline ?? Container::get('Pipeline');
 }
示例#3
0
 public static function tearDownAfterClass()
 {
     $dbRunIds = [self::$testRunId, self::$testRunIdUpdate];
     $conn = Container::get('Database')->getConnection();
     $stmt = $conn->prepare('DELETE FROM runs WHERE run_id = :run_id');
     foreach ($dbRunIds as $runId) {
         $stmt->bindValue(':run_id', $runId);
         $stmt->execute();
     }
 }
示例#4
0
 /**
  * Constructor
  *
  * @param   Config  $config
  *
  * @throws  ConfigValueMissingException
  */
 public function __construct(Config $config = null)
 {
     $config = $config ?? Container::get('Config');
     if (empty($config['database']['dsn'])) {
         throw new ConfigValueMissingException('missing database dsn');
     }
     if (empty($config['database']['username'])) {
         throw new ConfigValueMissingException('missing database user');
     }
     $this->dsn = $config['database']['dsn'];
     $this->username = $config['database']['username'];
     $this->password = $config['database']['password'] ?? '';
     $this->options = $config['database']['options'] ?? [];
 }
示例#5
0
<?php

use Fractile\Config;
use Fractile\Container;
require_once __DIR__ . '/../vendor/autoload.php';
// setup testing environment
Container::set('Config', new Config(__DIR__ . '/fixtures/config.php'));
示例#6
0
 /**
  * Constructor
  *
  * @param   RunRepository   $runRepository
  */
 public function __construct(RunRepository $runRepository = null)
 {
     $this->runRepository = $runRepository ?? Container::get('RunRepository');
 }
示例#7
0
 /**
  * Constructor
  *
  * @param   Database    $database
  * @param   RunFactory  $runFactory
  */
 public function __construct(Database $database = null, RunFactory $runFactory = null)
 {
     $this->database = $database ?? Container::get('Database');
     $this->runFactory = $runFactory ?? Container::get('RunDataFactory');
 }
示例#8
0
 public function testConnectionSucceeded()
 {
     $config = Container::get('Config');
     $database = new Database($config);
     $this->assertInstanceOf('\\PDO', $database->getConnection());
 }
示例#9
0
 /**
  * Constructor
  *
  * @param   IdGenerator     $idGenerator
  */
 public function __construct(IdGenerator $idGenerator = null)
 {
     $this->idGenerator = $idGenerator ?? Container::get('RunIdGenerator');
 }