Youshido\Tests\Library\Utilities\ErrorContainerTraitTest::testAdding PHP Method

testAdding() public method

public testAdding ( )
    public function testAdding()
    {
        $error = new \Exception('Error');
        $this->addError($error);
        $this->assertTrue($this->hasErrors());
        $this->clearErrors();
        $this->assertFalse($this->hasErrors());
        $this->addError($error);
        $this->assertEquals([$error], $this->getErrors());
        $this->mergeErrors($this);
        $this->assertEquals([$error, $error], $this->getErrors());
        $this->clearErrors();
        $this->addError(new DatableResolveException('Wrong data', 412, ['user_id' => '1']));
        $this->assertEquals([['message' => 'Wrong data', 'code' => 412, 'user_id' => '1']], $this->getErrorsArray());
        $this->clearErrors();
        $this->addError(new ConfigurationException('Invalid name'));
        $this->assertEquals([['message' => 'Invalid name']], $this->getErrorsArray());
    }
ErrorContainerTraitTest