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