Skip to content

Commit 108b658

Browse files
committed
Update PHPUnit to version 7 (old version 4.9 wasnt supported by PHP 7.1+)
* Update test-run.py and lib/tarantool_server.py to support python 3 * Update tests accordingly to new version of PHPUnit * Added initialization of standart class properties to 'Tarantool'
1 parent 3820b83 commit 108b658

12 files changed

+50056
-57160
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Makefile.in
2121
/config.nice
2222
/config.status
2323
/config.sub
24+
/configure.ac
2425
/configure.in
2526
/libtool
2627
/ltmain.sh

lib/tarantool_server.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,17 @@ def execute_no_reconnect(self, command):
9595
if not command:
9696
return
9797
cmd = command.replace('\n', ' ') + '\n'
98-
self.socket.sendall(cmd)
98+
self.socket.sendall(cmd.encode())
9999

100100
bufsiz = 4096
101-
res = ""
101+
res = b''
102102

103103
while True:
104104
buf = self.socket.recv(bufsiz)
105105
if not buf:
106106
break
107107
res = res + buf
108-
if (res.rfind("\n...\n") >= 0 or res.rfind("\r\n...\r\n") >= 0):
108+
if (res.rfind(b'\n...\n') >= 0 or res.rfind(b'\r\n...\r\n') >= 0):
109109
break
110110

111111
return yaml.load(res)
@@ -245,7 +245,7 @@ def start(self):
245245
self.generate_configuration()
246246
if self.script:
247247
shutil.copy(self.script, self.script_dst)
248-
os.chmod(self.script_dst, 0777)
248+
os.chmod(self.script_dst, 511)
249249
args = self.prepare_args()
250250
self.process = subprocess.Popen(args,
251251
cwd = self.vardir,

src/tarantool.c

+1
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@ static zend_object *tarantool_create(zend_class_entry *entry) {
391391
obj = (tarantool_object *)pecalloc(1, sizeof(tarantool_object) +
392392
sizeof(zval) * (entry->default_properties_count - 1), 0);
393393
zend_object_std_init(&obj->zo, entry);
394+
object_properties_init(&obj->zo, entry);
394395
obj->zo.handlers = &tarantool_obj_handlers;
395396

396397
return &obj->zo;

test-run.py

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python2.7
1+
#!/usr/bin/env python
22

33
import os
44
import sys
@@ -12,6 +12,8 @@
1212

1313
from pprint import pprint
1414

15+
PHPUNIT_PHAR = 'phpunit.phar'
16+
1517
def read_popen(cmd):
1618
path = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
1719
path.wait()
@@ -22,7 +24,7 @@ def read_popen_config(cmd):
2224
return read_popen(cmd)
2325

2426
def find_php_bin():
25-
path = read_popen('which php').strip()
27+
path = read_popen('which php').strip().decode()
2628
if (path.find('phpenv') != -1):
2729
version = read_popen('phpenv global')
2830
if (version.find('system') != -1):
@@ -37,7 +39,7 @@ def prepare_env(php_ini):
3739
os.mkdir('var')
3840
shutil.copy('test/shared/phpunit.xml', 'var')
3941
test_dir_path = os.path.abspath(os.path.join(os.getcwd(), 'test'))
40-
test_lib_path = os.path.join(test_dir_path, 'phpunit.phar')
42+
test_lib_path = os.path.join(test_dir_path, PHPUNIT_PHAR)
4143
# shutil.copy('test/shared/tarantool.ini', 'var')
4244
shutil.copy(php_ini, 'var')
4345
shutil.copy('modules/tarantool.so', 'var')
@@ -60,10 +62,10 @@ def main():
6062
try:
6163
shutil.copy('test/shared/phpunit.xml', os.path.join(test_cwd, 'phpunit.xml'))
6264
shutil.copy('modules/tarantool.so', test_cwd)
63-
test_lib_path = os.path.join(test_dir_path, 'phpunit.phar')
65+
test_lib_path = os.path.join(test_dir_path, PHPUNIT_PHAR)
6466

65-
version = read_popen_config('--version').strip(' \n\t') + '.'
66-
version1 = read_popen_config('--extension-dir').strip(' \n\t')
67+
version = read_popen_config('--version').decode().strip(' \n\t') + '.'
68+
version1 = read_popen_config('--extension-dir').decode().strip(' \n\t')
6769
version += '\n' + ('With' if version1.find('non-zts') == -1 else 'Without') + ' ZTS'
6870
version += '\n' + ('With' if version1.find('no-debug') == -1 else 'Without') + ' Debug'
6971
print('Running against ' + version)
@@ -100,9 +102,9 @@ def main():
100102
cmd = cmd + 'sudo dtruss ' + find_php_bin()
101103
cmd = cmd + ' -c tarantool.ini {0}'.format(test_lib_path)
102104
else:
103-
print find_php_bin()
105+
print(find_php_bin())
104106
cmd = '{0} -c tarantool.ini {1}'.format(find_php_bin(), test_lib_path)
105-
print cmd
107+
print(cmd)
106108

107109
print('Running "%s" with "%s"' % (cmd, php_ini))
108110
proc = subprocess.Popen(cmd, shell=True, cwd=test_cwd)

test/AssertTest.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
2-
class AssertTest extends PHPUnit_Framework_TestCase
2+
3+
use PHPUnit\Framework\TestCase;
4+
5+
final class AssertTest extends TestCase
36
{
47
protected static $tarantool, $tm;
58

@@ -39,6 +42,9 @@ function assert_f()
3942
self::$tarantool->select("test");
4043
}
4144

45+
/**
46+
* @doesNotPerformAssertions
47+
*/
4248
public function test_01_closed_connection() {
4349
for ($i = 0; $i < 20000; $i++) {
4450
try {

test/CreateTest.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?php
22

3-
class CreateTest extends PHPUnit_Framework_TestCase
3+
use PHPUnit\Framework\TestCase;
4+
5+
final class CreateTest extends TestCase
46
{
57
protected static $port, $tm;
68

@@ -34,6 +36,9 @@ public function test_01_create_test_ping_and_close() {
3436
$c->close();
3537
}
3638

39+
/**
40+
* @doesNotPerformAssertions
41+
*/
3742
public function test_01_01_double_disconnect() {
3843
$a = new Tarantool('localhost', self::$port);
3944
$a->disconnect();
@@ -42,7 +47,7 @@ public function test_01_01_double_disconnect() {
4247

4348
/**
4449
* @expectedException TarantoolException
45-
* @expectedExceptionMessageRegExp /Name or service not known|nodename nor servname provided/
50+
* @expectedExceptionMessageRegExp /Name or service not known|nodename nor servname provided|getaddrinfo/
4651
*/
4752
public function test_02_create_error_host() {
4853
(new Tarantool('very_bad_host'))->connect();

test/DMLTest.php

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
2-
class DMLTest extends PHPUnit_Framework_TestCase
2+
3+
use PHPUnit\Framework\TestCase;
4+
5+
final class DMLTest extends TestCase
36
{
47
protected static $tarantool;
58

@@ -158,6 +161,9 @@ public function test_06_update() {
158161
$this->assertEquals($result_tuple, $tuple[0]);
159162
}
160163

164+
/**
165+
* @doesNotPerformAssertions
166+
*/
161167
public function test_07_update_no_error() {
162168
self::$tarantool->update("test", 0, array());
163169
}
@@ -439,6 +445,9 @@ public static function provideIteratorGood() {
439445
];
440446
}
441447

448+
/**
449+
* @doesNotPerformAssertions
450+
*/
442451
public function test_18_01_delete_loop() {
443452
for ($i = 0; $i <= 1000; $i++) {
444453
self::$tarantool->replace("pstring", array("test2" . $i, $i));
@@ -451,6 +460,9 @@ public function test_18_01_delete_loop() {
451460
gc_collect_cycles();
452461
}
453462

463+
/**
464+
* @doesNotPerformAssertions
465+
*/
454466
public function test_18_02_delete_loop() {
455467
for ($i = 0; $i <= 1000; $i++) {
456468
self::$tarantool->replace("pstring", array("test2" . $i, $i));

test/MockTest.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
<?php
2-
class MockTest extends \PHPUnit_Framework_TestCase
2+
3+
use PHPUnit\Framework\TestCase;
4+
5+
final class MockTest extends TestCase
36
{
47
public function testFoo()
58
{
6-
$tnt = $this->getMock('Tarantool');
9+
// $tnt = $this->createMock(['Tarantool']);
10+
$tnt = $this->createMock(\Tarantool::class);
711
$tnt->expects($this->once())->method('ping');
812
$tnt->ping();
913
}

test/MsgPackTest.php

+15-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
2-
class MsgPackTest extends PHPUnit_Framework_TestCase
2+
3+
use PHPUnit\Framework\TestCase;
4+
5+
final class MsgPackTest extends TestCase
36
{
47
protected static $tarantool;
58

@@ -48,6 +51,9 @@ public function test_03_msgpack_array_of_float_as_key() {
4851
self::$tarantool->select("msgpack", array(3));
4952
}
5053

54+
/**
55+
* @doesNotPerformAssertions
56+
*/
5157
public function test_04_msgpack_integer_keys_arrays() {
5258
self::$tarantool->replace("msgpack", array(4,
5359
"Integer keys causing server to error",
@@ -70,11 +76,12 @@ public function test_05_msgpack_string_keys() {
7076
$this->assertTrue(True);
7177
}
7278

73-
public function test_06_msgpack_array_reference() {
74-
$data = [
75-
'key1' => 'value1',
76-
];
77-
$link = &$data['key1'];
78-
self::$tarantool->call('test_4', [$data]);
79-
}
79+
/**
80+
* @doesNotPerformAssertions
81+
*/
82+
public function test_06_msgpack_array_reference() {
83+
$data = [ 'key1' => 'value1', ];
84+
$link = &$data['key1'];
85+
self::$tarantool->call('test_4', [$data]);
86+
}
8087
}

test/RandomTest.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ function generateRandomString($length = 10) {
1010
return $randomString;
1111
}
1212

13-
class RandomTest extends PHPUnit_Framework_TestCase
13+
use PHPUnit\Framework\TestCase;
14+
15+
final class RandomTest extends TestCase
1416
{
1517
protected static $tarantool;
1618

@@ -39,6 +41,10 @@ public function test_03_another_big_response() {
3941
$this->assertEquals($i, count($result));
4042
}
4143
}
44+
45+
/**
46+
* @doesNotPerformAssertions
47+
*/
4248
public function test_04_get_strange_response() {
4349
self::$tarantool->select("_schema", "12345");
4450
}

test/phpunit

-1
This file was deleted.

0 commit comments

Comments
 (0)