diff --git a/src/Model/Fulfilment/OrderLine.php b/src/Model/Fulfilment/OrderLine.php index f4201d9d..6d31ca4a 100644 --- a/src/Model/Fulfilment/OrderLine.php +++ b/src/Model/Fulfilment/OrderLine.php @@ -73,6 +73,10 @@ public function __construct(array $data = []) $this->product = new Product($data['product'] ?? []); } + public function __toString() { + return (string) self::class; + } + /** * @return array */ diff --git a/src/Support/Collection.php b/src/Support/Collection.php index 1bd85e34..27af538d 100644 --- a/src/Support/Collection.php +++ b/src/Support/Collection.php @@ -1732,11 +1732,15 @@ static function ($value) { return Helpers::toArrayWithoutNull($value); } - if ($value && method_exists((string) $value, 'toArrayWithoutNull')) { + if (is_int($value)) { + return $value; + } + + if ($value && method_exists($value, 'toArrayWithoutNull')) { return $value->toArrayWithoutNull(); } - if ($value && method_exists((string) $value, 'toArray')) { + if ($value && method_exists($value, 'toArray')) { return $value->toArray(); } diff --git a/test/Support/CollectionTest.php b/test/Support/CollectionTest.php index a0020b96..a3a68fe8 100644 --- a/test/Support/CollectionTest.php +++ b/test/Support/CollectionTest.php @@ -55,6 +55,6 @@ public static function provideToArrayWithoutNullData(): array */ public function testToArrayWithoutNull(array $input, array $output): void { - self::assertSame(((new Collection($input))->toArrayWithoutNull()), $output); + self::assertSame($output, ((new Collection($input))->toArrayWithoutNull())); } } diff --git a/test/Validator/AbstractValidatorTest.php b/test/Validator/AbstractValidatorTest.php index e157807c..c94d5f1b 100644 --- a/test/Validator/AbstractValidatorTest.php +++ b/test/Validator/AbstractValidatorTest.php @@ -60,13 +60,11 @@ public function testValidator(array $rules): void (new $testValidator()) ->validateAll(true) ->report(); + self::fail(); } catch (ValidationException $e) { self::assertSame(['Error', 'Error', 'Error'], $e->getErrors()); $this->addToAssertionCount(1); } - - // Make sure the catch assertion has been executed. - self::assertEquals(1, $this->getNumAssertions()); } /**