public function __construct(\myfinance\FinanceContext $context) { $this->context = $context; $this->userId = $context->getUser()->id; $this->db = $this->context->getDb(); $this->db->connect(); }
public function testGetUser() { $dbMock = \Phake::mock('myfinance\\db\\DB'); $userMock = \Phake::mock('myfinance\\model\\User'); $context = new FinanceContext($dbMock, $userMock); $result = $context->getUser(); $this->assertEquals($userMock, $result); }
public static function create(\myfinance\FinanceContext $context) { if ($context->getDb() instanceof \myfinance\db\MysqlDB) { return new \myfinance\repositories\MysqlQuotaRepository($context); } else { return new \myfinance\repositories\DummyQuotaRepository($context); } }