Exemple #1
0
    public function testMarshalling()
    {
        $expectedXml = <<<XML
<?xml version="1.0"?>
<purchase-order xmlns="http://openuri.org/easypo">
  <customer>
    <name>Gladys Kravitz</name>
    <address>Anytown, PA</address>
  </customer>
  <date>2003-01-07T14:16:00-05:00</date>
  <line-item>
    <description>Burnham's Celestial Handbook, Vol 1</description>
    <per-unit-ounces>5</per-unit-ounces>
    <price>21.79</price>
    <quantity>2</quantity>
  </line-item>
  <line-item>
    <description>Burnham's Celestial Handbook, Vol 2</description>
    <per-unit-ounces>5</per-unit-ounces>
    <price>19.89</price>
    <quantity>2</quantity>
  </line-item>
  <shipper>
    <name>ZipShip</name>
    <per-ounce-rate>0.74</per-ounce-rate>
  </shipper>
</purchase-order>
XML;
        $filepath = dirname(__FILE__) . '/../../_files/EasyPO/';
        $binding = new PiBX_Runtime_Binding($filepath . '/binding.xml');
        $marshaller = new PiBX_Runtime_Marshaller($binding);
        $po = new PurchaseOrder();
        $po->setDate('2003-01-07T14:16:00-05:00');
        $customer = new Customer();
        $customer->setName('Gladys Kravitz');
        $customer->setAddress('Anytown, PA');
        $lineItem1 = new LineItem();
        $lineItem1->setDescription('Burnham\'s Celestial Handbook, Vol 1');
        $lineItem1->setPerUnitOunces('5');
        $lineItem1->setPrice(21.79);
        $lineItem1->setQuantity(2);
        $lineItem2 = new LineItem();
        $lineItem2->setDescription('Burnham\'s Celestial Handbook, Vol 2');
        $lineItem2->setPerUnitOunces('5');
        $lineItem2->setPrice(19.89);
        $lineItem2->setQuantity(2);
        $shipper = new Shipper();
        $shipper->setName('ZipShip');
        $shipper->setPerOunceRate(0.74);
        $po->setCustomer($customer);
        $po->setLineItems(array($lineItem1, $lineItem2));
        $po->setShipper($shipper);
        $xml = $marshaller->marshal($po);
        $this->assertEquals($expectedXml, $xml);
        $dom = new DOMDocument();
        $dom->loadXML($xml);
        $this->assertTrue($dom->schemaValidate($filepath . '/easypo.xsd'));
    }
function createBuyer()
{
    $buyer = new Customer();
    $buyer->setMail("*****@*****.**");
    $buyer->setName("Comprador Teste");
    $buyer->setCpf("850-822-365-04");
    $buyer->setPhone("34-3311-9999");
    $buyer->setCellPhone("34-9999-1111");
    $buyer->setAddress(createAddress());
    $buyer->setGender(GenderEnum::MALE);
    $buyer->setBirthDate("01/01/1970");
    $buyer->setRg("11337733");
    $buyer->setIssueRgDate("01/01/1990");
    $buyer->setOrganConsignorRg("SSP");
    $buyer->setStateConsignorRg("MG");
    $buyer->setCompanyName("Empresa de teste");
    $buyer->setCnpj("72-139-715/0001-30");
    $buyer->setSearchToken("");
    return $buyer;
}
 protected function runPage()
 {
     if (WebRequest::wasPosted()) {
         if (!WebRequest::postInt("calroom")) {
             $this->showCal();
             return;
         }
         $startdate = new DateTime(WebRequest::post("qbCheckin"));
         $enddate = new DateTime(WebRequest::post("qbCheckout"));
         $room = Room::getById(WebRequest::postInt("calroom"));
         for ($date = $startdate; $date < $enddate; $date->modify("+1 day")) {
             if (!$room->isAvailable($date)) {
                 $this->error("room-not-available");
                 $this->showCal();
                 return;
             }
         }
         // search for customer
         if (!($customer = Customer::getByEmail(WebRequest::post("qbEmail")))) {
             $customer = new Customer();
             $suTitle = WebRequest::post("qbTitle");
             $suFirstname = WebRequest::post("qbFirstname");
             $suLastname = WebRequest::post("qbLastname");
             $suAddress = WebRequest::post("qbAddress");
             $suCity = WebRequest::post("qbCity");
             $suPostcode = WebRequest::post("qbPostcode");
             $suCountry = WebRequest::post("qbCountry");
             $suEmail = WebRequest::post("qbEmail");
             $customer->setPassword($suEmail);
             // set values
             $customer->setTitle($suTitle);
             $customer->setFirstname($suFirstname);
             $customer->setSurname($suLastname);
             $address = new Address();
             $address->setLine1($suAddress);
             $address->setCity($suCity);
             $address->setPostCode($suPostcode);
             $address->setCountry($suCountry);
             $address->save();
             $customer->setAddress($address);
             $customer->setEmail($suEmail);
             // save it
             $customer->save();
             $customer->sendMailConfirm();
             // save it again
             $customer->save();
         }
         $booking = new Booking();
         $booking->setStartDate(WebRequest::post("qbCheckin"));
         $booking->setEndDate(WebRequest::post("qbCheckout"));
         $booking->setAdults(WebRequest::post("qbAdults"));
         $booking->setChildren(WebRequest::post("qbChildren"));
         $booking->setPromocode(WebRequest::post("qbPromoCode"));
         $booking->setRoom($room->getId());
         $booking->setCustomer($customer->getId());
         $booking->save();
         $msg = Message::getMessage("booking-confirmation");
         $msg = str_replace("\$1", $booking->getStartDate(), $msg);
         $msg = str_replace("\$2", $booking->getEndDate(), $msg);
         $msg = str_replace("\$3", $booking->getAdults(), $msg);
         $msg = str_replace("\$4", $booking->getChildren(), $msg);
         $msg = str_replace("\$5", $booking->getRoom()->getName(), $msg);
         Mail::send($customer->getEmail(), Message::getMessage("booking-confimation-subject"), $msg);
         $this->mSmarty->assign("content", $msg);
         return;
     }
     throw new YouShouldntBeDoingThatException();
 }
 /**
  * 配達情報
  * route --> /customer/accepted
  */
 public function acceptedAction()
 {
     $this->_log->debug(__CLASS__ . ":" . __FUNCTION__ . " called:(" . __LINE__ . ")");
     $customerID = Auth::getUserID();
     // 配達者
     $params = $this->getPostList();
     if (count($params) == 0) {
         $this->_log->debug("パラメータがPOSTされていません.");
         return;
     }
     if ($params['report'] == 1) {
         $this->_log->debug("配達が不許可でした.");
         return;
     }
     /* 配達を許可した場合(配達者に表示) */
     unset($params['report']);
     $params['deliverymanID'] = $customerID;
     $mapper = new Customer();
     $itemsInCart = $mapper->receiveRequest($params);
     $this->setViewSearchlist($itemsInCart);
     $indata = array('requestID' => $params['requestID'], 'address' => $mapper->setAddress($params['requestID']));
     $this->setViewIndata($indata);
     return;
 }
 public function getAllCustomers()
 {
     $customerList = array();
     $result = $this->db->query('SELECT * FROM Customer');
     foreach ($result as $row) {
         $custDetails = new Customer();
         $custDetails->setId($row['id']);
         $custDetails->setCustomerName($row['customerName']);
         $custDetails->setEmail($row['email']);
         $custDetails->setPhoneNumber($row['phoneNumber']);
         $custDetails->setAddress($row['address']);
         $custDetails->setPassword($row['password']);
         $custDetails->setLastUpdate($row['lastUpdate']);
         $customerList[$custDetails->getId()] = $custDetails;
     }
     return $customerList;
 }
 /**
  *@expectedException InvalidArgumentException
  */
 public function testShouldThrowsAnExceptionWhenSettingAnInvalidArgument()
 {
     $instance = new Customer();
     $instance->setAddress(1);
 }
 private function showCreateCustomerPage()
 {
     if (WebRequest::wasPosted()) {
         try {
             // get variables
             $suTitle = WebRequest::post("suTitle");
             $suFirstname = WebRequest::post("suFirstname");
             $suLastname = WebRequest::post("suLastname");
             $suAddress = WebRequest::post("suAddress");
             $suCity = WebRequest::post("suCity");
             $suPostcode = WebRequest::post("suPostcode");
             $suCountry = WebRequest::post("suCountry");
             $suEmail = WebRequest::post("suEmail");
             $suPassword = WebRequest::post("suPassword");
             $suConfirm = WebRequest::post("suConfirm");
             // data validation
             if ($suTitle == "") {
                 throw new CreateCustomerException("suTitle not specified");
             }
             if ($suFirstname == "") {
                 throw new CreateCustomerException("suFirstname not specified");
             }
             if ($suLastname == "") {
                 throw new CreateCustomerException("suLastname not specified");
             }
             if ($suAddress == "") {
                 throw new CreateCustomerException("suAddress not specified");
             }
             if ($suCity == "") {
                 throw new CreateCustomerException("suCity not specified");
             }
             if ($suPostcode == "") {
                 throw new CreateCustomerException("suPostcode not specified");
             }
             if ($suCountry == "") {
                 throw new CreateCustomerException("suCountry not specified");
             }
             if ($suEmail == "") {
                 throw new CreateCustomerException("suEmail not specified");
             }
             if ($suPassword == "") {
                 throw new CreateCustomerException("suPassword not specified");
             }
             if ($suConfirm == "") {
                 throw new CreateCustomerException("suConfirm not specified");
             }
             if ($suPassword != $suConfirm) {
                 throw new CreateCustomerException("Password mismatch");
             }
             $customer = new Customer();
             // set values
             $customer->setTitle($suTitle);
             $customer->setFirstname($suFirstname);
             $customer->setSurname($suLastname);
             $address = new Address();
             $address->setLine1($suAddress);
             $address->setCity($suCity);
             $address->setPostcode($suPostcode);
             $address->setCountry($suCountry);
             $address->save();
             $customer->setAddress($address);
             $customer->setEmail($suEmail);
             $customer->setPassword($suPassword);
             $customer->sendMailConfirm();
             // save it
             $customer->save();
             global $cScriptPath;
             $this->mHeaders[] = "Location: {$cScriptPath}/Customers";
         } catch (CreateCustomerException $ex) {
             $this->mBasePage = "mgmt/custCreate.tpl";
             $this->error($ex->getMessage());
         }
     } else {
         $this->mBasePage = "mgmt/custCreate.tpl";
     }
 }
 protected function runPage()
 {
     $showError = "";
     $error = "";
     global $cWebPath;
     $this->mBasePage = "signup.tpl";
     if (Session::isCustomerLoggedIn()) {
         // why do you want another account?
         // redirect to main page
         $this->mHeaders[] = "HTTP/1.1 303 See Other";
         $this->mHeaders[] = "Location: " . $cWebPath . "/index.php";
     }
     if (WebRequest::wasPosted()) {
         try {
             $suTitle = WebRequest::post("suTitle");
             $suFirstname = WebRequest::post("suFirstname");
             $suLastname = WebRequest::post("suLastname");
             $suAddress = WebRequest::post("suAddress");
             $suCity = WebRequest::post("suCity");
             $suPostcode = WebRequest::post("suPostcode");
             $suCountry = WebRequest::post("suCountry");
             $suEmail = WebRequest::post("suEmail");
             $suPassword = WebRequest::post("suPassword");
             $suConfirm = WebRequest::post("suConfirm");
             // data validation
             if ($suTitle == "") {
                 throw new CreateCustomerException("Title not specified");
             }
             if ($suFirstname == "") {
                 throw new CreateCustomerException("Firstname not specified");
             }
             if ($suLastname == "") {
                 throw new CreateCustomerException("Lastname not specified");
             }
             if ($suAddress == "") {
                 throw new CreateCustomerException("Address not specified");
             }
             if ($suCity == "") {
                 throw new CreateCustomerException("City not specified");
             }
             if ($suPostcode == "") {
                 throw new CreateCustomerException("Postcode not specified");
             }
             if ($suCountry == "") {
                 throw new CreateCustomerException("Country not specified");
             }
             if ($suEmail == "") {
                 throw new CreateCustomerException("Email not specified");
             }
             if ($suPassword == "") {
                 throw new CreateCustomerException("Password not specified");
             }
             if ($suConfirm == "") {
                 throw new CreateCustomerException("Confirmed password not specified");
             }
             if ($suPassword != $suConfirm) {
                 throw new CreateCustomerException("Password mismatch");
             }
             $customer = new Customer();
             if ($suPassword != "" && $suPassword == $suConfirm) {
                 $customer->setPassword($suPassword);
             }
             // set values
             $customer->setTitle($suTitle);
             $customer->setFirstname($suFirstname);
             $customer->setSurname($suLastname);
             $address = new Address();
             $address->setLine1($suAddress);
             $address->setCity($suCity);
             $address->setPostCode($suPostcode);
             $address->setCountry($suCountry);
             $address->save();
             $customer->setAddress($address);
             $customer->setEmail($suEmail);
             // save it
             $customer->save();
             $customer->sendMailConfirm();
             global $cScriptPath;
             $this->mHeaders[] = "Location: {$cScriptPath}";
         } catch (CreateCustomerException $ex) {
             $this->mBasePage = "signup.tpl";
             $this->error($ex->getMessage());
         }
     } else {
         $this->mBasePage = "signup.tpl";
     }
 }