示例#1
0
 public function testCanAccessValidationErrorsFromCommand()
 {
     $validationErrors = array('[Foo] Baz', '[Bar] Boo');
     $command = new MockCommand();
     $command->setClient(new \Guzzle\Service\Client());
     $this->assertFalse($command->getValidationErrors());
     $v = $this->getMockBuilder('Guzzle\\Service\\Description\\SchemaValidator')->setMethods(array('validate', 'getErrors'))->getMock();
     $v->expects($this->any())->method('getErrors')->will($this->returnValue($validationErrors));
     $command->setValidator($v);
     $this->assertEquals($validationErrors, $command->getValidationErrors());
 }
 /**
  * @expectedException \Guzzle\Service\Exception\ValidationException
  * @expectedExceptionMessage [Foo] Baz
  */
 public function testValidatesCommandBeforeSending()
 {
     $command = new MockCommand();
     $command->setClient(new \Guzzle\Service\Client());
     $v = $this->getMockBuilder('Guzzle\\Service\\Description\\SchemaValidator')->setMethods(array('validate', 'getErrors'))->getMock();
     $v->expects($this->any())->method('validate')->will($this->returnValue(false));
     $v->expects($this->any())->method('getErrors')->will($this->returnValue(array('[Foo] Baz', '[Bar] Boo')));
     $command->setValidator($v);
     $command->prepare();
 }