|
4 | 4 |
|
5 | 5 | class AssertTest extends TestCase
|
6 | 6 | {
|
7 |
| - use TestCaseCompat; |
8 |
| - |
9 |
| - protected static $tarantool, $tm; |
10 |
| - |
11 |
| - public static function doSetUpBeforeClass() { |
12 |
| - self::$tm = ini_get("tarantool.request_timeout"); |
13 |
| - ini_set("tarantool.request_timeout", "0.1"); |
14 |
| - self::$tarantool = new Tarantool('localhost', getenv('PRIMARY_PORT')); |
15 |
| - self::$tarantool->authenticate('test', 'test'); |
16 |
| - } |
17 |
| - |
18 |
| - public static function doTearDownAfterClass() { |
19 |
| - ini_set("tarantool.request_timeout", self::$tm); |
20 |
| - } |
21 |
| - |
22 |
| - protected function doTearDown() { |
23 |
| - $tuples = self::$tarantool->select("test"); |
24 |
| - foreach($tuples as $value) |
25 |
| - self::$tarantool->delete("test", Array($value[0])); |
26 |
| - } |
27 |
| - |
28 |
| - public function test_00_timedout() { |
29 |
| - self::$tarantool->eval(" |
30 |
| - function assert_f() |
31 |
| - os.execute('sleep 1') |
32 |
| - return 0 |
33 |
| - end"); |
34 |
| - try { |
35 |
| - $result = self::$tarantool->call("assert_f"); |
36 |
| - $this->assertFalse(True); |
37 |
| - } catch (TarantoolException $e) { |
38 |
| - // print($e->getMessage()); |
39 |
| - $this->assertStringContainsString( |
40 |
| - "Failed to read", $e->getMessage()); |
41 |
| - } |
42 |
| - |
43 |
| - /* We can reconnect and everything will be ok */ |
44 |
| - self::$tarantool->close(); |
45 |
| - self::$tarantool->select("test"); |
46 |
| - } |
47 |
| - |
48 |
| - /** |
49 |
| - * @doesNotPerformAssertions |
50 |
| - */ |
51 |
| - public function test_01_closed_connection() { |
52 |
| - for ($i = 0; $i < 20000; $i++) { |
53 |
| - try { |
54 |
| - self::$tarantool->call("nonexistentfunction"); |
55 |
| - } catch (TarantoolClientError $e) { |
56 |
| - continue; |
57 |
| - } |
58 |
| - } |
59 |
| - } |
| 7 | + use TestCaseCompat; |
| 8 | + |
| 9 | + protected static $tarantool, $tm; |
| 10 | + |
| 11 | + public static function doSetUpBeforeClass() { |
| 12 | + self::$tm = ini_get("tarantool.request_timeout"); |
| 13 | + ini_set("tarantool.request_timeout", "0.1"); |
| 14 | + self::$tarantool = new Tarantool('localhost', getenv('PRIMARY_PORT')); |
| 15 | + self::$tarantool->authenticate('test', 'test'); |
| 16 | + } |
| 17 | + |
| 18 | + public static function doTearDownAfterClass() { |
| 19 | + ini_set("tarantool.request_timeout", self::$tm); |
| 20 | + } |
| 21 | + |
| 22 | + protected function doTearDown() { |
| 23 | + $tuples = self::$tarantool->select("test"); |
| 24 | + foreach($tuples as $value) |
| 25 | + self::$tarantool->delete("test", Array($value[0])); |
| 26 | + } |
| 27 | + |
| 28 | + public function test_00_timedout() { |
| 29 | + self::$tarantool->eval(" |
| 30 | + function assert_f() |
| 31 | + os.execute('sleep 1') |
| 32 | + return 0 |
| 33 | + end"); |
| 34 | + try { |
| 35 | + $result = self::$tarantool->call("assert_f"); |
| 36 | + $this->assertFalse(True); |
| 37 | + } catch (TarantoolException $e) { |
| 38 | + // print($e->getMessage()); |
| 39 | + $this->assertStringContainsString( |
| 40 | + "Failed to read", $e->getMessage()); |
| 41 | + } |
| 42 | + |
| 43 | + /* We can reconnect and everything will be ok */ |
| 44 | + self::$tarantool->close(); |
| 45 | + self::$tarantool->select("test"); |
| 46 | + } |
| 47 | + |
| 48 | + /** |
| 49 | + * @doesNotPerformAssertions |
| 50 | + */ |
| 51 | + public function test_01_closed_connection() { |
| 52 | + for ($i = 0; $i < 20000; $i++) { |
| 53 | + try { |
| 54 | + self::$tarantool->call("nonexistentfunction"); |
| 55 | + } catch (TarantoolClientError $e) { |
| 56 | + continue; |
| 57 | + } |
| 58 | + } |
| 59 | + } |
60 | 60 | }
|
0 commit comments