Closed (outdated)
Project:
Drupal core
Version:
8.3.x-dev
Component:
simpletest.module
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
20 Dec 2012 at 00:16 UTC
Updated:
7 Jul 2017 at 03:44 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
dawehnerThere seems to be no specific tests for the assertions, or they are hard to find :)
Comment #2
dawehner#1: drupal-1870786-1.patch queued for re-testing.
Comment #3
Anonymous (not verified) commentedI created such a method for my test suite (in D7). It deepen compares the arrays and provides the trace to the differing elements in the error message:
I've seen this when using PHPunit in another project end wanted this fine granuar approach in Drupal and simpletest.
It's not feature complete (but works for me). It needs support for Objects and some other general features...
Comment #4
damiankloip commentedThe patch looks good, and it still applies :) I am just thinking, this will only check that all the values are the same, is it work also doing a version with array_diff_key?
Comment #5
dawehnerso what about assertArrayEqual and assertArrayKeyEqual?
Comment #6
alansaviolobo commentedwouldnt the logic be similar to assertIdenticalObject() in the same file ?
Comment #7
jhedstromUsing
array_diff()will only work on the top-level, and won't work for multidimensional arrays. Not sure if that's relevant for this use case or not, but if it is, perhaps a second assertion that utilizesDiffArray::diffAssocRecursive?Comment #8
mpp commentedHave a look at PHP Unit. I would have expected array assertions like assertContains, assertArrayHasKey etc:: https://phpunit.de/manual/current/en/appendixes.assertions.html
Note that PHP Unit has a mixed argument assertEquals()
Comment #12
mile23Current PHPUnit framework tests have assertEquals(), which can compare arrays. The solution to adding this assertion to TestBase-based tests is to convert to BrowserTestBase: https://www.drupal.org/node/2783189