public function testSourcePointerConvertsDotNotation() { $messages = new MessageBag(['foo.bar.baz' => 'Some detail']); $expected = new Error(); $expected->setSourcePointer('/data/attributes/foo/bar/baz')->setDetail('Some detail'); $bag = new ErrorBag($messages, null, '/data/attributes'); $this->assertEquals($expected, current($bag->toArray())); }
public function testAddErrorWithPointer() { $expected = new Error('123'); $expected->setDetail('Expecting to see bar as the value'); $expected->setSourcePointer($pointer = '/foo/bar'); $this->willSee('my-error', '123', 'Expecting to see {foo} as the value'); $this->assertEquals($expected, $this->addErrorWithPointer('my-error', $pointer, ['foo' => 'bar'])); $this->assertError($expected); }