|
7 | 7 | use PDOException; |
8 | 8 | use Phinx\Config\Config; |
9 | 9 | use PHPUnit\Framework\TestCase; |
| 10 | +use ReflectionMethod; |
10 | 11 | use RuntimeException; |
11 | 12 | use Test\Phinx\DeprecationException; |
12 | 13 | use Test\Phinx\TestUtils; |
@@ -203,4 +204,46 @@ public function testExecuteRightTrimsSemiColons() |
203 | 204 | $this->adapter->setConnection($pdo); |
204 | 205 | $this->adapter->execute('SELECT 1;;'); |
205 | 206 | } |
| 207 | + |
| 208 | + public function testQuoteValueNumeric() |
| 209 | + { |
| 210 | + $method = new ReflectionMethod($this->adapter, 'quoteValue'); |
| 211 | + $this->assertSame(1.0, $method->invoke($this->adapter, 1.0)); |
| 212 | + $this->assertSame(2, $method->invoke($this->adapter, 2)); |
| 213 | + } |
| 214 | + |
| 215 | + public function testQuoteValueBoolean() |
| 216 | + { |
| 217 | + $method = new ReflectionMethod($this->adapter, 'quoteValue'); |
| 218 | + $this->assertSame(1, $method->invoke($this->adapter, true)); |
| 219 | + $this->assertSame(0, $method->invoke($this->adapter, false)); |
| 220 | + } |
| 221 | + |
| 222 | + public function testQuoteValueNull() |
| 223 | + { |
| 224 | + $method = new ReflectionMethod($this->adapter, 'quoteValue'); |
| 225 | + $this->assertSame('null', $method->invoke($this->adapter, null)); |
| 226 | + } |
| 227 | + |
| 228 | + public function testQuoteValueString() |
| 229 | + { |
| 230 | + $mockValue = 'mockvalue'; |
| 231 | + $expectedValue = 'mockvalueexpected'; |
| 232 | + |
| 233 | + /** @var \PDO&\PHPUnit\Framework\MockObject\MockObject $pdo */ |
| 234 | + $pdo = $this->getMockBuilder(PDO::class) |
| 235 | + ->disableOriginalConstructor() |
| 236 | + ->onlyMethods(['quote']) |
| 237 | + ->getMock(); |
| 238 | + |
| 239 | + $pdo->expects($this->once()) |
| 240 | + ->method('quote') |
| 241 | + ->with($mockValue) |
| 242 | + ->willReturn($expectedValue); |
| 243 | + |
| 244 | + $this->adapter->setConnection($pdo); |
| 245 | + |
| 246 | + $method = new ReflectionMethod($this->adapter, 'quoteValue'); |
| 247 | + $this->assertSame($expectedValue, $method->invoke($this->adapter, $mockValue)); |
| 248 | + } |
206 | 249 | } |
0 commit comments