@@ 68-87 (lines=20) @@ | ||
65 | * |
|
66 | * @expectedException \Hgraca\MicroDbal\Raw\Exception\BindingException |
|
67 | */ |
|
68 | public function executeQuery_ShouldThrowExceptionIfCantBind() |
|
69 | { |
|
70 | $sql = 'some dummy sql'; |
|
71 | $parameterList = [ |
|
72 | 'trueVal' => true, |
|
73 | ]; |
|
74 | ||
75 | $pdoStatementMock = Mockery::mock(PDOStatement::class); |
|
76 | $this->pdo->shouldReceive('prepare')->once()->with($sql)->andReturn($pdoStatementMock); |
|
77 | $pdoStatementMock->shouldReceive('bindValue') |
|
78 | ->once() |
|
79 | ->with('trueVal', $parameterList['trueVal'], PDO::PARAM_BOOL) |
|
80 | ->andReturn(false); |
|
81 | ||
82 | $pdoStatementMock->shouldReceive('execute')->once()->andReturn(false); |
|
83 | $pdoStatementMock->shouldReceive('errorCode')->once()->andReturn('123'); |
|
84 | $pdoStatementMock->shouldReceive('errorInfo')->once()->andReturn(['some error info']); |
|
85 | ||
86 | $this->client->executeQuery($sql, $parameterList); |
|
87 | } |
|
88 | ||
89 | /** |
|
90 | * @test |
|
@@ 96-115 (lines=20) @@ | ||
93 | * |
|
94 | * @expectedException \Hgraca\MicroDbal\Raw\Exception\ExecutionException |
|
95 | */ |
|
96 | public function executeQuery_ShouldThrowExceptionIfCantExecute() |
|
97 | { |
|
98 | $sql = 'some dummy sql'; |
|
99 | $parameterList = [ |
|
100 | 'trueVal' => true, |
|
101 | ]; |
|
102 | ||
103 | $pdoStatementMock = Mockery::mock(PDOStatement::class); |
|
104 | $this->pdo->shouldReceive('prepare')->once()->with($sql)->andReturn($pdoStatementMock); |
|
105 | $pdoStatementMock->shouldReceive('bindValue') |
|
106 | ->once() |
|
107 | ->with('trueVal', $parameterList['trueVal'], PDO::PARAM_BOOL) |
|
108 | ->andReturn(true); |
|
109 | ||
110 | $pdoStatementMock->shouldReceive('execute')->once()->andReturn(false); |
|
111 | $pdoStatementMock->shouldReceive('errorCode')->once()->andReturn('123'); |
|
112 | $pdoStatementMock->shouldReceive('errorInfo')->once()->andReturn(['some error info']); |
|
113 | ||
114 | $this->client->executeQuery($sql, $parameterList); |
|
115 | } |
|
116 | ||
117 | /** |
|
118 | * @test |