'bar', 'something' => ['baz', 'foo'], ]; $barValue = print_r(['baz', 'foo'], true); $expectedStringRepresentation = << bar 'something' => {$barValue} EOT; $inputFilter = $this->createMock(InputFilterInterface::class); $inputFilter->expects($this->once())->method('getMessages')->with()->willReturn($invalidData); $e = ValidationException::fromInputFilter($inputFilter, $prev); self::assertEquals($invalidData, $e->getInvalidElements()); self::assertEquals(['invalidElements' => array_keys($invalidData)], $e->getAdditionalData()); self::assertEquals('Provided data is not valid', $e->getMessage()); self::assertEquals(StatusCodeInterface::STATUS_BAD_REQUEST, $e->getCode()); self::assertEquals($prev, $e->getPrevious()); self::assertStringContainsString($expectedStringRepresentation, (string) $e); } public static function provideExceptions(): iterable { return [[null], [new RuntimeException()], [new LogicException()]]; } }