| Conditions | 1 |
| Paths | 1 |
| Total Lines | 23 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | public function testCounterIncreaseDecrease() |
||
| 10 | { |
||
| 11 | self::$connection->query('CREATE TABLE CounterTest (row_key text, test_counter counter, PRIMARY KEY (row_key));'); |
||
| 12 | |||
| 13 | self::$connection->query( |
||
| 14 | 'UPDATE CounterTest SET "test_counter" = "test_counter" + :increase_value where "row_key" = :row_key', |
||
| 15 | ['increase_value' => 1000, 'row_key' => 'KEY'] |
||
| 16 | ); |
||
| 17 | $result = self::$connection->query( |
||
| 18 | 'SELECT * FROM CounterTest WHERE row_key = :row_key', ['row_key' => 'KEY'] |
||
| 19 | ); |
||
| 20 | $this->assertFloatEquals(1000, $result[0]['test_counter']); |
||
| 21 | |||
| 22 | self::$connection->query( |
||
| 23 | 'UPDATE CounterTest SET "test_counter" = "test_counter" + :increase_value where "row_key" = :row_key', |
||
| 24 | ['increase_value' => -2000, 'row_key' => 'KEY'] |
||
| 25 | ); |
||
| 26 | |||
| 27 | $result = self::$connection->query( |
||
| 28 | 'SELECT * FROM CounterTest WHERE row_key = :row_key', ['row_key' => 'KEY'] |
||
| 29 | ); |
||
| 30 | $this->assertFloatEquals(-1000, $result[0]['test_counter']); |
||
| 31 | } |
||
| 32 | } |
||
| 33 |