|
1 | 1 | <?php |
2 | 2 | class AssertTest extends PHPUnit_Framework_TestCase |
3 | 3 | { |
4 | | - protected static $tarantool, $tm; |
| 4 | + protected static $tarantool, $tm; |
5 | 5 |
|
6 | | - public static function setUpBeforeClass() |
7 | | - { |
8 | | - self::$tm = ini_get("tarantool.request_timeout"); |
9 | | - ini_set("tarantool.request_timeout", "0.1"); |
10 | | - self::$tarantool = new Tarantool('localhost', getenv('PRIMARY_PORT')); |
11 | | - self::$tarantool->authenticate('test', 'test'); |
12 | | - } |
| 6 | + public static function setUpBeforeClass() { |
| 7 | + self::$tm = ini_get("tarantool.request_timeout"); |
| 8 | + ini_set("tarantool.request_timeout", "0.1"); |
| 9 | + self::$tarantool = new Tarantool('localhost', getenv('PRIMARY_PORT')); |
| 10 | + self::$tarantool->authenticate('test', 'test'); |
| 11 | + } |
13 | 12 |
|
14 | | - public static function tearDownAfterClass() { |
15 | | - ini_set("tarantool.request_timeout", self::$tm); |
16 | | - } |
| 13 | + public static function tearDownAfterClass() { |
| 14 | + ini_set("tarantool.request_timeout", self::$tm); |
| 15 | + } |
17 | 16 |
|
18 | | - protected function tearDown() |
19 | | - { |
20 | | - $tuples = self::$tarantool->select("test"); |
21 | | - foreach($tuples as $value) |
22 | | - self::$tarantool->delete("test", Array($value[0])); |
23 | | - } |
| 17 | + protected function tearDown() { |
| 18 | + $tuples = self::$tarantool->select("test"); |
| 19 | + foreach($tuples as $value) |
| 20 | + self::$tarantool->delete("test", Array($value[0])); |
| 21 | + } |
24 | 22 |
|
25 | | - public function test_00_timedout() { |
| 23 | + public function test_00_timedout() { |
| 24 | + self::$tarantool->eval(" |
| 25 | + function assertf() |
| 26 | + require('fiber').sleep(1) |
| 27 | + return 0 |
| 28 | + end"); |
| 29 | + try { |
| 30 | + self::$tarantool->call("assertf"); |
| 31 | + $this->assertFalse(True); |
| 32 | + } catch (Exception $e) { |
| 33 | + $this->assertTrue(strpos($e->getMessage(), "Can't read query") !== False); |
| 34 | + } |
26 | 35 |
|
27 | | - self::$tarantool->eval(" |
28 | | - function assertf() |
29 | | - require('fiber').sleep(1) |
30 | | - return 0 |
31 | | - end"); |
32 | | - try { |
33 | | - self::$tarantool->call("assertf"); |
34 | | - $this->assertFalse(True); |
35 | | - } catch (Exception $e) { |
36 | | - $this->assertTrue(strpos($e->getMessage(), |
37 | | - "Can't read query") !== False); |
38 | | - } |
| 36 | + /* We can reconnect and everything will be ok */ |
| 37 | + self::$tarantool->select("test"); |
| 38 | + } |
39 | 39 |
|
40 | | - /* We can reconnect and everything will be ok */ |
41 | | - self::$tarantool->select("test"); |
42 | | - } |
| 40 | + public function test_01_closed_connection() { |
| 41 | + for ($i = 0; $i < 20000; $i++) { |
| 42 | + try { |
| 43 | + self::$tarantool->call("nonexistentfunction"); |
| 44 | + } catch (Exception $e) { |
| 45 | + $this->assertTrue(strpos($e->getMessage(), "is not defined") !== False); |
| 46 | + } |
| 47 | + } |
| 48 | + } |
43 | 49 | } |
0 commit comments