/** * DbRequest::isResultBuffer: true * DbRequest::getResultType: name (MYSQLI_ASSOC) * DbRequest::getCallback throws an exception * * @depends testInitialState * @return null */ public function testExecuteProfileF() { $driver = $this->getDriver(); $adapter = $this->getAdapter(); $sql = $this->getSql(); $request = new DbRequest($sql); $request->setValues(array(1, 2, 3)); $errMsg = "error has occured"; $func = function ($row) use($errMsg) { throw new Exception($errMsg, 99); }; $request->setCallback($func); $response = new DbResponse(); $result = $adapter->execute($driver, $request, $response); $this->assertSame($response, $result); $this->assertTrue($response->isError()); $stack = $response->getErrorStack(); $this->assertEquals(3, $stack->count()); $error = $stack->current(); $idx = 0; $expected = "error has occured -(0)"; $this->assertEquals(99, $error->getCode()); $this->assertEquals($expected, $error->getMessage()); $idx = 1; $expected = "error has occured -(1)"; $stack->next(); $error = $stack->current(); $this->assertEquals(99, $error->getCode()); $this->assertEquals($expected, $error->getMessage()); $expected = "error has occured -(2)"; $stack->next(); $error = $stack->current(); $this->assertEquals(99, $error->getCode()); $this->assertEquals($expected, $error->getMessage()); }
/** * DbRequest::isResultBuffer: true * DbRequest::getResultType: name (MYSQLI_ASSOC) * DbRequest::getCallback throws an exception * * @depends testInitialState * @return null */ public function testExecuteProfileF() { $driver = $this->getDriver(); $adapter = $this->getQueryAdapter(); $sql = $this->getSql(); $request = new DbRequest($sql); $errMsg = "error as occured"; $func = function ($row) use($errMsg) { if ('code_b' === $row['param_2']) { throw new Exception($errMsg, 99); } return array('new_param_2' => $row['param_2'], 'new_result' => $row['result']); }; $request->setCallback($func); $response = new DbResponse(); $result = $adapter->execute($driver, $request, $response); $this->assertSame($response, $result); $this->assertTrue($response->isError()); $stack = $response->getErrorStack(); $this->assertEquals(1, $stack->count()); $error = $stack->current(); $class = get_class($adapter); $expected = "{$errMsg} -(1)"; $results = $response->getResultSet(); $this->assertEquals(99, $error->getCode()); $this->assertEquals($expected, $error->getMessage()); }