pecl-memcache
pecl-memcache copied to clipboard
Test in Symfony's HttpFoundation failing with websupport-sk/pecl-memcache under PHP 7
Note: Referencing this from symfony/symfony#17873 in which a proposed fix for Symfony was rejected with the wish to fix this upstream (in websupport-sk/pecl-memcache).
Problem
Using websupport-sk/pecl-memcache (branch php7 / commit 88750b4203914bc3c40b485cfa139e3094e0fd04) with PHP 7 a test in Symfony's HttpFoundation (v3.0.2) component is failing with the following error:
# php7.0 -f /tmp/phpunit.phar -- src/Symfony/Component/HttpFoundation
PHPUnit 5.2.9 by Sebastian Bergmann and contributors.
............................................................... 63 / 809 ( 7%)
................................................S.............. 126 / 809 ( 15%)
...................................................S........... 189 / 809 ( 23%)
............................................................... 252 / 809 ( 31%)
............................................................... 315 / 809 ( 38%)
..............................................SS............... 378 / 809 ( 46%)
S.............................................................. 441 / 809 ( 54%)
............................................................... 504 / 809 ( 62%)
............................................................... 567 / 809 ( 70%)
............................................................... 630 / 809 ( 77%)
........................................................E...... 693 / 809 ( 85%)
..SSSSSSSSSSSSSSSSSSSSSS..........SSSSSSSSSSSSSSS.............. 756 / 809 ( 93%)
..................................................... 809 / 809 (100%)
Time: 8.4 seconds, Memory: 14.00Mb
There was 1 error:
1) Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler\MemcacheSessionHandlerTest::testReadSession
Missing argument 2 for Mock_Memcache_f8a5b6df::get(), called in /tmp/dabe/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcacheSessionHandler.php on line 82 and defined
/tmp/dabe/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcacheSessionHandler.php:82
/tmp/dabe/symfony/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php:72
FAILURES!
Tests: 1239, Assertions: 1658, Errors: 1, Skipped: 42.
This does does not happen with the PHP5 version of websupport-sk/pecl-memcache (branch NON_BLOCKING_IO_php7 / commit fdbd46bbc6f53ed6e024521895e142cbfc9b3340):
# php5 -f /tmp/phpunit.phar -- src/Symfony/Component/HttpFoundation
PHPUnit 5.2.9 by Sebastian Bergmann and contributors.
............................................................... 63 / 809 ( 7%)
................................................S.............. 126 / 809 ( 15%)
...................................................S........... 189 / 809 ( 23%)
............................................................... 252 / 809 ( 31%)
............................................................... 315 / 809 ( 38%)
..............................................SS............... 378 / 809 ( 46%)
S.............................................................. 441 / 809 ( 54%)
............................................................... 504 / 809 ( 62%)
............................................................... 567 / 809 ( 70%)
............................................................... 630 / 809 ( 77%)
............................................................... 693 / 809 ( 85%)
..SSSSSSSSSSSSSSSSSSSSSS..........SSSSSSSSSSSSSSS.............. 756 / 809 ( 93%)
..................................................... 809 / 809 (100%)
Time: 10.24 seconds, Memory: 23.25Mb
OK, but incomplete, skipped, or risky tests!
Tests: 1239, Assertions: 1660, Skipped: 42.
How to reproduce
- Build websupport-sk/pecl-memcache for php7 and configure php7 to use it
- Get composer and phpunit in place
- Checkout Symfony:
# git clone https://github.com/symfony/symfony.git && cd symfony
- Reset Symfony to v3.0.2:
# git reset --hard v3.0.2
- Install dependencies using composer:
# composer install
- Run tests for HttpFoundation component:
# phpunit src/Symfony/Component/HttpFoundation
Further information
The mocked object generated by phpunit is different for the php7 and the php5 version:
diff -u php5.mock.php php7.mock.php
--- php5.mock.php 2016-02-28 12:08:01.521713978 +0100
+++ php7.mock.php 2016-02-28 12:06:48.600997172 +0100
@@ -1,4 +1,4 @@
-class Mock_Memcache_988c5512 extends Memcache implements PHPUnit_Framework_MockObject_MockObject
+class Mock_Memcache_2739b378 extends Memcache implements PHPUnit_Framework_MockObject_MockObject
{
private $__phpunit_invocationMocker;
private $__phpunit_originalObject;
@@ -316,15 +316,15 @@
return $result;
}
- public function get()
+ public function get($arg0, &$arg1, &$arg2)
{
- $arguments = array();
+ $arguments = array($arg0, &$arg1, &$arg2);
$count = func_num_args();
- if ($count > 0) {
+ if ($count > 3) {
$_arguments = func_get_args();
- for ($i = 0; $i < $count; $i++) {
+ for ($i = 3; $i < $count; $i++) {
$arguments[] = $_arguments[$i];
}
}
Thus I suspect to the php7 version exposes something different through the reflection API, than the php5 version does.
i reproduced it, skips are because of missing memcached (not memcache), and mongo, ... i have 2 failing tests
PHPUnit 5.2.10 by Sebastian Bergmann and contributors.
Runtime: PHP 7.0.5-dev
Configuration: /home/baloghsz/src/pecl-memcache/test2/symfony/phpunit.xml.dist
............................................................... 63 / 809 ( 7%)
............................................................... 126 / 809 ( 15%)
...................................................S........... 189 / 809 ( 23%)
............................................................... 252 / 809 ( 31%)
............................................................... 315 / 809 ( 38%)
..............................................SS............... 378 / 809 ( 46%)
S.............................................................. 441 / 809 ( 54%)
............................................................... 504 / 809 ( 62%)
............................................................... 567 / 809 ( 70%)
............................................................... 630 / 809 ( 77%)
........................................................E...... 693 / 809 ( 85%)
..SSSSSSSSSSSSSSSSSSSSSS.....E................................. 756 / 809 ( 93%)
..................................................... 809 / 809 (100%)
Time: 5.73 seconds, Memory: 14.00Mb
There were 2 errors:
1) Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler\MemcacheSessionHandlerTest::testReadSession
Missing argument 2 for Mock_Memcache_75ed4e5a::get(), called in /home/baloghsz/src/pecl-memcache/test2/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcacheSessionHandler.php on line 82 and defined
/home/baloghsz/src/pecl-memcache/test2/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcacheSessionHandler.php:82
/home/baloghsz/src/pecl-memcache/test2/symfony/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php:72
2) Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler\NativeFileSessionHandlerTest::testConstructDefault
is_dir(): Unable to find the wrapper "tcp" - did you forget to enable it when you configured PHP?
/home/baloghsz/src/pecl-memcache/test2/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php:51
/home/baloghsz/src/pecl-memcache/test2/symfony/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php:72
-
mock. It is about function get, implemented as PHP_FUNCTION(memcache_get). in input parameters there is no change, so what i changed: This function uses zend_parse_parameters, and is returning flags to a reference from function parameters. There was a change in references, so if i would to do it in php7, i needed to define it in https://github.com/websupport-sk/pecl-memcache/blob/NON_BLOCKING_IO_php7/php7/memcache.c#L96, so there was added definition https://github.com/websupport-sk/pecl-memcache/blob/NON_BLOCKING_IO_php7/php7/memcache.c#L48, which there wasn't before.
So parameters as seen in zend_parse_parameters were not changed, but there is added a definition, so now mock can discover about parameters. Can I overcome this in this module, or should be fixed elsewhere?
-
I don't know why is NativeFileSessionHandlerTest testing session.save_path if session.save_handler = "memcache". I didn't changed naming of configuration parameters for this module, so this should be the same for php5 before, but i didn't verified this.
Not sure about #2. I have to check.
for #1, arg_info is missing for many APIs, we should definitively complete them at some points :) That looks like what is used by phpunit to valid the mock interface.
@pierrejoye I am noticing this also on our current build. Do you have an ETA For #1 (or even a work around?).