Beispiel #1
0
 /**
  * (non-PHPdoc)
  * @see PHPUnit_Framework_TestCase::setUp()
  */
 public function setUp()
 {
     parent::setUp();
     $expAddress = new Address();
     $expAddress->setLine2('Address Line 2');
     $expAddress->setPostalCode('34000');
     $expAddress->setCity('City');
     $destAddress = new AddressDest();
     $destAddress->setName('Name');
     $destAddress->setSurname('Surname');
     $destAddress->setEmail('*****@*****.**');
     $destAddress->setLine2('Address Line 2');
     $destAddress->setPostalCode('34000');
     $destAddress->setCity('City');
     $this->context = new ServiceCallContext('ACME');
     $this->parcel = new Parcel(0.72);
     $this->expEnv = new ExpEnv($expAddress);
     $this->destEnv = new DestEnv($destAddress);
     $this->letter = new Letter();
     $this->letter->setContractNumber('111111');
     $this->letter->setPassword('password');
     $this->letter->setService($this->context);
     $this->letter->setParcel($this->parcel);
     $this->letter->setExp($this->expEnv);
     $this->letter->setDest($this->destEnv);
     $this->letter->setProfil(null);
 }
Beispiel #2
0
$expAddress->setCompanyName('Acme and Co');
$expAddress->setLine2('Place de la Comedie');
$expAddress->setPostalCode('34000');
$expAddress->setCity('Montpellier');
// build the recipient address
$destAddress = new AddressDest();
$destAddress->setCivility('M');
$destAddress->setName('Prenom');
$destAddress->setSurname('Nom');
$destAddress->setLine2('Place de la Comedie');
$destAddress->setPostalCode('34000');
$destAddress->setCity('Montpellier');
$destAddress->setPhone('0606060606');
$destAddress->setEmail('*****@*****.**');
// build the main letter object
$letter = new Letter();
$letter->setContractNumber($parameters['account']);
$letter->setPassword($parameters['password']);
$letter->setService(new ServiceCallContext('Acme and Co'));
$letter->setParcel(new Parcel(0.72));
$letter->setExp(new ExpEnv($expAddress));
$letter->setDest(new DestEnv($destAddress));
// test service availability // optionnal
$checker = new ServiceAvailability();
$checker->check();
// test letter object validity // optionnal
$validator = Validation::createValidatorBuilder()->addMethodMapping('loadValidatorMetadata')->getValidator();
$violations = $validator->validate($letter);
if (count($violations) === 0) {
    // create the webservice client
    $clientBuilder = new ClientBuilder();
 /**
  * Build the LetterColissimoRequest to pass to the client
  *
  * @param array $parcelData
  * @param array $recipientData
  * @param array $senderData
  *
  * @return \WSColissimo\WSColiPosteLetterService\Request\LetterColissimoRequest
  */
 protected function buildLetterColissimoRequest(array $parcelData, array $recipientData, array $senderData = array())
 {
     $letter = new Letter();
     $letter->setContractNumber($this->params['contract_number']);
     $letter->setPassword($this->params['password']);
     $parcel = $this->getParcelFromArray($parcelData);
     $letter->setParcel($parcel);
     $service = $this->getServiceFromConfig();
     $letter->setService($service);
     $exp = count($senderData) > 0 ? $this->getExpFromArray($senderData) : $this->getExpFromConfig();
     $letter->setExp($exp);
     $dest = $this->getDestFromArray($recipientData);
     $letter->setDest($dest);
     $request = new LetterColissimoRequest();
     $request->setLetter($letter);
     return $request;
 }