/** * Test validation in the setters */ public function testFaultyProperties() { $box = new Box(); try { $box->setStatus(str_repeat('a', 10)); } catch (\Exception $e) { $this->assertInstanceOf('TijsVerkoyen\\Bpost\\Exception', $e); $this->assertEquals('Invalid value, possible values are: ' . implode(', ', Box::getPossibleStatusValues()) . '.', $e->getMessage()); } }
/** * Modify the status for an order. * * @param string $reference The reference for an order * @param string $status The new status, allowed values are: OPEN, PENDING, CANCELLED, COMPLETED, ON-HOLD or PRINTED * @return bool */ public function modifyOrderStatus($reference, $status) { $status = strtoupper($status); if (!in_array($status, Box::getPossibleStatusValues())) { throw new Exception(sprintf('Invalid value, possible values are: %1$s.', implode(', ', Box::getPossibleStatusValues()))); } $url = '/orders/' . $reference; $document = new \DOMDocument('1.0', 'utf-8'); $document->preserveWhiteSpace = false; $document->formatOutput = true; $orderUpdate = $document->createElement('orderUpdate'); $orderUpdate->setAttribute('xmlns', 'http://schema.post.be/shm/deepintegration/v3/'); $orderUpdate->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); $orderUpdate->appendChild($document->createElement('status', $status)); $document->appendChild($orderUpdate); $headers = array('Content-type: application/vnd.bpost.shm-orderUpdate-v3+XML'); return $this->doCall($url, $document->saveXML(), $headers, 'POST', false) == ''; }