Exemplo n.º 1
0
 public function testLifecycle()
 {
     $key = static::class;
     $this->assertNull(Container::get($key));
     Container::set($key, $this);
     $this->assertEquals($this, Container::get($key));
 }
Exemplo n.º 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');
 }
Exemplo n.º 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();
     }
 }
Exemplo n.º 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'] ?? [];
 }
Exemplo n.º 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'));
Exemplo n.º 6
0
 /**
  * Constructor
  *
  * @param   RunRepository   $runRepository
  */
 public function __construct(RunRepository $runRepository = null)
 {
     $this->runRepository = $runRepository ?? Container::get('RunRepository');
 }
Exemplo n.º 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');
 }
Exemplo n.º 8
0
 public function testConnectionSucceeded()
 {
     $config = Container::get('Config');
     $database = new Database($config);
     $this->assertInstanceOf('\\PDO', $database->getConnection());
 }
Exemplo n.º 9
0
 /**
  * Constructor
  *
  * @param   IdGenerator     $idGenerator
  */
 public function __construct(IdGenerator $idGenerator = null)
 {
     $this->idGenerator = $idGenerator ?? Container::get('RunIdGenerator');
 }