You are here

protected function SortArrayTest::assertBothNegativePositiveOrZero in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Component/Utility/SortArrayTest.php \Drupal\Tests\Component\Utility\SortArrayTest::assertBothNegativePositiveOrZero()

Asserts that numbers are either both negative, both positive or both zero.

The exact values returned by comparison functions differ between PHP versions and are considered an "implementation detail".

Parameters

int $expected: Expected comparison function return value.

int $result: Actual comparison function return value.

4 calls to SortArrayTest::assertBothNegativePositiveOrZero()
SortArrayTest::testSortByTitleElement in core/tests/Drupal/Tests/Component/Utility/SortArrayTest.php
Tests SortArray::sortByTitleElement() input against expected output.
SortArrayTest::testSortByTitleProperty in core/tests/Drupal/Tests/Component/Utility/SortArrayTest.php
Tests SortArray::sortByTitleProperty() input against expected output.
SortArrayTest::testSortByWeightElement in core/tests/Drupal/Tests/Component/Utility/SortArrayTest.php
Tests SortArray::sortByWeightElement() input against expected output.
SortArrayTest::testSortByWeightProperty in core/tests/Drupal/Tests/Component/Utility/SortArrayTest.php
Tests SortArray::sortByWeightProperty() input against expected output.

File

core/tests/Drupal/Tests/Component/Utility/SortArrayTest.php, line 323
Contains \Drupal\Tests\Component\Utility\SortArrayTest.

Class

SortArrayTest
Tests the SortArray component.

Namespace

Drupal\Tests\Component\Utility

Code

protected function assertBothNegativePositiveOrZero($expected, $result) {
  $this
    ->assertTrue(is_numeric($expected) && is_numeric($result), 'Parameters are numeric.');
  $this
    ->assertTrue($expected < 0 && $result < 0 || $expected > 0 && $result > 0 || $expected === 0 && $result === 0, 'Numbers are either both negative, both positive or both zero.');
}