/**
  * Perform a basic code generation/request/response scenario.
  */
 public function testCurrencyConvertor()
 {
     // Run the code generator.
     $this->generator->generate($this->config);
     // Test that we have the expected files and classes.
     $expected_classes = array('CurrencyConvertor', 'ConversionRate', 'Currency', 'ConversionRateResponse');
     foreach ($expected_classes as $class) {
         $file = $this->outputDir . '/' . $class . '.php';
         $this->assertFileExists($file);
         require_once $file;
         $this->assertClassExists($class);
     }
     // Make sure that we have expected constants and methods.
     $this->assertClassHasConst('USD', 'Currency');
     $this->assertClassHasConst('EUR', 'Currency');
     $this->assertClassHasMethod('ConversionRate', 'CurrencyConvertor');
     // Setup and execute the service call.
     $service = new CurrencyConvertor();
     $request = new ConversionRate(Currency::USD, Currency::EUR);
     $response = $service->ConversionRate($request);
     // Test that the response is as expected.
     $this->assertTrue(get_class($response) == 'ConversionRateResponse');
     // In the end the conversion rate between USD and EUR should be a numeric.
     // It is actually a double but this type does not seem to be supported by
     // assertAttributeInternalType().
     $this->assertAttributeInternalType('numeric', 'ConversionRateResult', $response);
 }
 /**
  * Perform a basic code generation/request/response scenario.
  *
  * @vcr CurrencyConverterTest_testCurrencyConvertor
  */
 public function testCurrencyConvertor()
 {
     // Test that we have the expected files and classes.
     $expected_classes = array('CurrencyConvertor', 'ConversionRate', 'Currency', 'ConversionRateResponse');
     foreach ($expected_classes as $class) {
         $this->assertGeneratedClassExists($class);
     }
     // Make sure that we have expected constants and methods.
     $this->assertClassHasConst('USD', 'Currency');
     $this->assertClassHasConst('EUR', 'Currency');
     $this->assertClassHasMethod('CurrencyConvertor', 'ConversionRate');
     // Setup and execute the service call.
     $service = new \CurrencyConvertor();
     $request = new \ConversionRate(\Currency::USD, \Currency::EUR);
     try {
         $response = $service->ConversionRate($request);
         // Test that the response is as expected.
         $this->assertTrue(get_class($response) == 'ConversionRateResponse');
         // In the end the conversion rate between USD and EUR should be a numeric.
         // It is actually a double but this type does not seem to be supported by
         // assertAttributeInternalType().
         $this->assertAttributeInternalType('numeric', 'ConversionRateResult', $response);
     } catch (SoapFault $e) {
         // If an exception is thrown it should be due to a timeout. We cannot
         // guard against this when calling an external service.
         $this->assertContains('timeout', $e->getMessage());
     }
 }
Exemplo n.º 3
0
 function get_availByCity($city_id = '', $checkin, $checkout, $roomscount, $passengers)
 {
     $json = json_encode(array(array('city_id' => strval($city_id), 'check_in' => str_replace('/', '-', $checkin), 'check_out' => str_replace('/', '-', $checkout), 'rooms' => $roomscount, 'passengers' => $passengers)));
     $c = $this->sendRequest('chk_avail_hotel_city', $json);
     $Hotels = array();
     $Hotels['min'] = 0;
     $Hotels['max'] = 1;
     foreach ($c as $hid => $hotel) {
         $Hotels[$hid]['id'] = $hid;
         $Hotels[$hid]['name'] = $hotel->hotel->name;
         $Hotels[$hid]['en_name'] = $hotel->hotel->en_name;
         $Hotels[$hid]['star'] = $hotel->hotel->star;
         $Hotels[$hid]['desc'] = $hotel->hotel->des;
         $Hotels[$hid]['thu'] = $hotel->hotel->thu;
         $Hotels[$hid]['en_des'] = $hotel->hotel->en_des;
         $Hotels[$hid]['price'] = 0;
         $cvtr = new CurrencyConvertor();
         foreach ($hotel->rooms as $k => $room) {
             $temp = array();
             foreach ($room as $j => $rm) {
                 $Hotels[$hid]['en_des'] = $hotel->hotel->en_des;
                 $temp[$j]['id'] = $j;
                 $temp[$j]['name'] = $rm->name;
                 $temp[$j]['en_name'] = $rm->en_name;
                 $temp[$j]['capa'] = $rm->capa_adult;
                 $temp[$j]['price'] = $rm->price;
                 if (!isset($_SESSION['currency_unit'])) {
                     $_SESSION['currency_unit'] = 'IRR';
                 }
                 $temp[$j]['currency'] = $rm->currency;
                 if ($_SESSION['currency_unit'] !== $temp[$j]['currency']) {
                     $temp[$j]['price'] = $cvtr->Convert($temp[$j]['currency'], $_SESSION['currency_unit'], $temp[$j]['price']);
                     $temp[$j]['currency'] = $_SESSION['currency_unit'];
                 }
                 $p = $temp[$j]['price'];
                 //                        if($p > $Hotels[$hid]['price'])
                 //                            $Hotels[$hid]['price'] = $p;
                 //                        if($p < $Hotels['min'])
                 //                            $Hotels['min'] = $p;
                 //                        if($p > $Hotels['max'])
                 //                            $Hotels['max'] =$p;
                 if ($p > $Hotels[$hid]['price']) {
                     $Hotels[$hid]['price'] = $p;
                 }
                 if ($p < $Hotels['min']) {
                     $Hotels['min'] = $p;
                 }
                 if ((int) $p > (int) $Hotels['max']) {
                     $Hotels['max'] = (int) $p;
                 }
                 //                            $Hotels['max'] = $p;
             }
             $Hotels[$hid]['rooms'][$k] = $temp;
         }
     }
     //echo '<pre>';
     //print_r($Hotels);exit;
     return $Hotels;
 }
Exemplo n.º 4
0
                        <div class="location-gallery clearfix">
                            <a href="#"><i class="icons-gallery"></i> تصاویر</a>
                            <a href="#"><i class="icons-map-location"></i>آدرس </a>
                        </div>
                    </div>
                    <div class="details col-md-8">
                        <div class="title"><?php 
        echo $hotel['name'];
        ?>
</div>
                        <?php 
        $rooms = array();
        $totalprice = 0;
        $rooms_id = '';
        $rooms_attr = array();
        $cvtr = new CurrencyConvertor();
        for ($f = 0; $f < $_SESSION['room-num']; $f++) {
            $rooms[$f] = $hotel['rooms'][$f];
        }
        for ($f = 0; $f < $_SESSION['room-num']; $f++) {
            $k = 1;
            foreach ($rooms[$f] as $rmindx => $room) {
                if ($_SESSION['currency_unit'] !== $room['currency']) {
                    $room['price'] = $cvtr->Convert($room['currency'], $_SESSION['currency_unit'], $room['price']);
                    $room['currency'] = $_SESSION['currency_unit'];
                }
                $totalprice += $room['price'];
                $MoneyUnit = $room['currency'];
                $rooms_id .= trim($room['id']) . ',';
                $attr = array('id' => $room['id'], 'en_name' => $room['en_name'], 'price' => $room['price']);
                array_push($rooms_attr, $attr);
Exemplo n.º 5
0
 function CheckHotelAvailRequest($request_id)
 {
     $json = $json = "[{\"request_id\":\"{$request_id}\"}]";
     $c = $this->sendRequest('HotelAvailResponse', $json);
     //check error status
     if (isset($c['err']['code']) && $c['err']['code'] != 0) {
         return json_encode($c);
     }
     //echo json_encode($c);
     //exit;
     $Hotels = array();
     $Hotels['min'] = 0;
     $Hotels['max'] = 0;
     foreach ($c as $hotel) {
         $Hotels[$hotel['id']]['id'] = $hotel['id'];
         $Hotels[$hotel['id']]['name'] = $hotel['name'];
         $Hotels[$hotel['id']]['en_name'] = $hotel['en_name'];
         $Hotels[$hotel['id']]['star'] = $hotel['star'];
         //$Hotels[$hotel['id']]['desc'] = $hotel['description'];
         //$Hotels[$hid]['thu'] = $hotel->hotel->thu;
         //$Hotels[$hotel['id']]['en_des'] = $hotel['en_description'];
         $Hotels[$hotel['id']]['price'] = 0;
         $cvtr = new CurrencyConvertor();
         foreach ($hotel['rooms'] as $rm) {
             $temp = array();
             $temp[$rm['id']]['id'] = $rm['id'];
             $temp[$rm['id']]['name'] = $rm['name'];
             $temp[$rm['id']]['en_name'] = $rm['en_name'];
             //$temp[$rm['id']]['capa'] = $rm['id'];
             $temp[$rm['id']]['price'] = $rm['price'];
             if (!isset($_SESSION['currency_unit'])) {
                 $_SESSION['currency_unit'] = 'IRR';
             }
             $temp[$rm['id']]['currency'] = $rm['currency'];
             if ($_SESSION['currency_unit'] !== $temp[$rm['id']]['currency']) {
                 $temp[$rm['id']]['price'] = $cvtr->Convert($temp[$rm['id']]['currency'], $_SESSION['currency_unit'], $temp[$rm['id']]['price']);
                 $temp[$rm['id']]['currency'] = $_SESSION['currency_unit'];
             }
             $p = (int) $temp[$rm['id']]['price'];
             if ((int) $p > (int) $Hotels[$hotel['id']]['price']) {
                 $Hotels[$hotel['id']]['price'] = (int) $p;
             }
             if ((int) $p < (int) $Hotels['min']) {
                 $Hotels['min'] = $p;
             }
             if ((int) $p > (int) $Hotels['max']) {
                 $Hotels['max'] = (int) $p;
             }
             $Hotels[$hotel['id']]['rooms'][] = $temp;
         }
     }
     return array('Hotels' => $Hotels, 'min' => $Hotels['min'], 'max' => $Hotels['max']);
 }