/** * @testdox Can check if instances are equals to other objects * @dataProvider IEquatableMethodArgumentsProvider */ public function testIEquatableEqualsMethod($expected, IEquatable $left, $right) { $actual = $left->equals($right); $message = String::format('$obj->{method}({right}); // Returned: {actual} ($obj: {left})', ['method' => 'equals', 'left' => static::export($left), 'right' => static::export($right), 'actual' => static::export($actual)]); $this->assertInternalType('boolean', $actual, $message); if (!is_bool($expected)) { throw new InvalidArgumentException(String::format('1st argument of data provider should be of "boolean" type, "{0}" given.', NML\typeof($expected))); } $this->assertEquals($expected, $actual, $message); $this->assertTrue($left->equals($left), '[Shold be equal to itself]'); }
public function testPerformsFormatWithArgumentsOfDifferentTypesConvertiblesToString() { $expected = 'Invalid argument type. "major" (position 0) must to be an instance of "integer"; "string" given.'; $major = 'Non Number'; $args = ['name' => 'major', 'expected' => NML\typeof(0), 'pos' => 0, 'actual' => NML\typeof($major)]; // Esto produce un error fatal debido a una debilidad en el uso de la función `asort` en el método // ``Cake\Utility\Text::.insert()``, ya que debería comparar como cadena usando el flag `SORT_STRING` // pero que se evita convirtiendo los valores a string en el método String::format(). $actual = String::format('Invalid argument type.', null); $actual .= String::format(' "{name}" (position {pos}) must to be an instance of "{expected}"; "{actual}" given.', $args); $this->assertEquals($expected, $actual); }