public function testErrorSetterMethods() { $o1 = new RestResponse(); $o1->setErrors(['first-error', 'second-error']); $o2 = new RestResponse(); $o2->addError('first-error')->addError('second-error'); $arr1 = $o1->asArray(); $arr2 = $o2->asArray(); $this->assertCount(2, $arr1['errors']); $this->assertCount(2, $arr2['errors']); $this->assertEquals('first-error', $arr1['errors'][0]); $this->assertEquals('second-error', $arr1['errors'][1]); $this->assertEquals('first-error', $arr2['errors'][0]); $this->assertEquals('second-error', $arr2['errors'][1]); $arrWithErrors1 = $o1->getErrors(); $arrWithErrors2 = $o2->getErrors(); $this->assertEquals('first-error', $arrWithErrors1[0]); $this->assertEquals('second-error', $arrWithErrors1[1]); $this->assertEquals('first-error', $arrWithErrors2[0]); $this->assertEquals('second-error', $arrWithErrors2[1]); }