/** * @test * * @covers Cocur\NQM\NQM::execute() */ public function convertParametersShouldNotAddColonIfItIsThere() { $this->pdo->mock('SELECT * FROM table WHERE key = :key;', [[':key' => 'foo']]); $this->queryLoader->shouldReceive('getQuery')->with('foo')->once()->andReturn('SELECT * FROM table WHERE key = :key;'); $stmt = $this->nqm->execute('foo', [':key' => 'foo']); $this->assertInstanceOf('\\PDOStatement', $stmt); $this->assertEquals([':key' => 'foo'], $stmt->fetch(\PDO::FETCH_ASSOC)); }
/** * @test * @covers Cocur\NQM\QueryLoader\CacheQueryLoader::getQuery() * @expectedException \Cocur\NQM\Exception\QueryNotExistsException */ public function getQueryThrowsExceptionIfQueryDoesNotExist() { $this->loader->shouldReceive('getQuery')->once()->andThrow('Cocur\\NQM\\Exception\\QueryNotExistsException'); $this->cache->getQuery('foo'); }