Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
We use array_diff to compare ...
$this->assertEquals(array_diff(array (
'x' => 'y',
'data' =>
array (
'a' => 1,
'b' => 2,
),
), $parsed['object']), array());
In php 5.4 this test gives a failure:
There was 1 error:
1) backendCase::testBackendMethodPost
Array to string conversion
The actual content of $parsed['object'] is:
Array
(
[x] => y
[data] => Array
(
[a] => 1
[b] => 2
)
[#id] => @none
)
So the "[#id]" key is something we only get in php 5.4?
Related: https://drupal.org/node/1511396#comment-6246736
and #1850798: Add a recursive version of array_diff_assoc()
I first tried to use the drupal_array_diff_assoc_recursive() for this test, but realized it could be simplified.
With the attached patch we get a proper failure in php 5.4.4, on 5.3.10 the test still passes.
There was 1 failure:
1) backendCase::testBackendMethodPost
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
Array (
'x' => 'y'
'data' => Array (...)
+ '#id' => '@none'
)
/home/helmo/src/drush/tests/backendTest.php:212
/home/helmo/src/drush/vendor/phpunit/phpunit/phpunit.php:46
FAILURES!
Tests: 1, Assertions: 2, Failures: 1.
Summary: This improves the failure... now we can look for a fix.
Comment | File | Size | Author |
---|---|---|---|
drush-simplify_testBackendMethodPost.patch | 554 bytes | helmo |
Comments
Comment #1
helmo CreditAttribution: helmo commentedStranger even... The "'#id' => '@none'" is absent on php 5.3.10 (ubuntu 12.04), but present on php 5.3.26 (Travis).
I'm testing the pull request scenario by sending myself one... https://github.com/helmo/drush/pull/1
Travis agrees that this fixes the test on their infra. https://travis-ci.org/helmo/drush/builds/8535153
Comment #2
moshe weitzman CreditAttribution: moshe weitzman commentedCommitted #1 to 5.x and 6.x. Moving to Active since it sounds like more detective work is needed.
Comment #3
moshe weitzman CreditAttribution: moshe weitzman commentedNow, the drush builds are failing on Travis - https://travis-ci.org/drush-ops/drush/jobs/8625204. I didn't understand that the patch here actually causes previously passing builds to fail on travis. At least thats what I am seeing. I'm tempted to roll this back so our tests are green. Please suggest another patch or give input if we would rather not roll back.
Comment #4
helmo CreditAttribution: helmo commentedIt seems that you've committed the patch from #0, not the pull request from #1
Comment #5
moshe weitzman CreditAttribution: moshe weitzman commentedCommitted.