/** * Checks if the office field is correctly serialized * * @depends testSetOffice */ public function testSetOfficeAndSerializes(Customer $customer) { $document = new CustomersDocument(); $document->addCustomer($customer); $xpath = new \DOMXPath($document); $this->assertEquals($xpath->query('/dimension/office')->item(0)->nodeValue, $this->office); }
/** * Sends a \Pronamic\Twinfield\Customer\Customer instance to Twinfield * to update or add. * * First attempts to login with the passed configuration in the constructor. * If successful will get the secure Service class. * * It will then make an instance of * \Pronamic\Twinfield\Customer\DOM\CustomersDocument where it will * pass in the Customer class in this methods parameter. * * It will then attempt to send the DOM document from CustomersDocument * and set the response to this instances method setResponse() (which you * can get with getResponse()) * * If successful will return true, else will return false. * * If you want to map the response back into a customer use getResponse()-> * getResponseDocument()->asXML() into the CustomerMapper::map method. * * @access public * @param \Pronamic\Twinfield\Customer\Customer $customer * @return boolean */ public function send(Customer $customer) { // Attempts the process login if ($this->getLogin()->process()) { // Gets the secure service $service = $this->getService(); // Gets a new instance of CustomersDocument and sets the $customer $customersDocument = new DOM\CustomersDocument(); $customersDocument->addCustomer($customer); // Send the DOM document request and set the response $response = $service->send($customersDocument); $this->setResponse($response); // Return a bool on status of response. if ($response->isSuccessful()) { return true; } else { return false; } } }