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.

CommentFileSizeAuthor
drush-simplify_testBackendMethodPost.patch554 byteshelmo
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

helmo’s picture

Status: Active » Needs review

Stranger 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

moshe weitzman’s picture

Status: Needs review » Active

Committed #1 to 5.x and 6.x. Moving to Active since it sounds like more detective work is needed.

moshe weitzman’s picture

Priority: Normal » Critical
Issue tags: +Release blocker

Now, 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.

helmo’s picture

It seems that you've committed the patch from #0, not the pull request from #1

moshe weitzman’s picture

Priority: Critical » Normal
Status: Active » Fixed
Issue tags: -Release blocker

Committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.