public function testSourceParameter() { $messages = new MessageBag(['foo.bar.baz' => 'Some detail']); $expected = new Error(); $expected->setSourceParameter('filter.foo.bar.baz')->setDetail('Some detail'); $bag = new ErrorBag($messages, null, 'filter', true); $this->assertEquals($expected, current($bag->toArray())); }
public function testAddErrorWithParameter() { $expected = new Error('123'); $expected->setDetail('Expecting to see bar as the value'); $expected->setSourceParameter($param = 'foobar'); $this->willSee('my-error', '123', 'Expecting to see {foo} as the value'); $this->assertEquals($expected, $this->addErrorWithParameter('my-error', $param, ['foo' => 'bar'])); $this->assertError($expected); }