Beispiel #1
0
 public function testDetach()
 {
     $request = new HTTP_Request2();
     $observer = new HTTP_Request2_MockObserver();
     $observer2 = new HTTP_Request2_MockObserver();
     $request->attach($observer);
     $request->detach($observer2);
     // should not be a error
     $request->setLastEvent('first');
     $request->detach($observer);
     $request->setLastEvent('second');
     $this->assertEquals(1, $observer->calls);
     $this->assertEquals(array('name' => 'first', 'data' => null), $observer->event);
 }
 /**
  * Accept
  *
  * @param mixed $object Object to accept
  *
  * @see getHTTPRequest2()
  * @return void
  */
 public function accept($object)
 {
     switch (get_class($object)) {
         case 'HTTP_Request2':
             $this->request = $object;
             foreach (self::$logs as $log) {
                 $this->request->attach(new HTTP_Request2_Observer_Log($log));
             }
             break;
         default:
             if ($object instanceof Log) {
                 HTTP_OAuth::attachLog($object);
                 $this->getHTTPRequest2()->attach(new HTTP_Request2_Observer_Log($object));
             }
             break;
     }
 }
 /**
  * Make the http request
  */
 public function main()
 {
     if (!isset($this->_url)) {
         throw new BuildException("Missing attribute 'url' set");
     }
     $request = new HTTP_Request2($this->_url);
     // set the authentication data
     if (!empty($this->_authUser)) {
         $request->setAuth($this->_authUser, $this->_authPassword, $this->_authScheme);
     }
     foreach ($this->_configData as $config) {
         $request->setConfig($config->getName(), $config->getValue());
     }
     foreach ($this->_headers as $header) {
         $request->setHeader($header->getName(), $header->getValue());
     }
     if ($this->_verbose) {
         $observer = new HTTP_Request2_Observer_Log();
         // set the events we want to log
         $observer->events = $this->_observerEvents;
         $request->attach($observer);
     }
     $response = $request->send();
     if ($this->_responseRegex !== '') {
         $matches = array();
         preg_match($this->_responseRegex, $response->getBody(), $matches);
         if (count($matches) === 0) {
             throw new BuildException('The received response body did not match the ' . 'given regular expression');
         } else {
             $this->log('The response body matched the provided regex.');
         }
     }
 }
<?php

require_once 'Hawk/LixiServiceClient.php';
require_once 'Log.php';
require_once 'HTTP/Request2/Observer/Log.php';
$log = Log::factory("console");
date_default_timezone_set('Australia/Adelaide');
$endpoint = 'http://127.0.0.1:3000/lixi/';
// $endpoint = 'http://functional-test.htw.com.au/lixi/';
// $endpoint = 'https://staging.htw.com.au/lixi/';
$request = new HTTP_Request2($endpoint);
$request->setAuth("User", "Pass", HTTP_Request2::AUTH_BASIC);
$request->setConfig('ssl_verify_peer', false);
$observer = new HTTP_Request2_Observer_Log($log);
$request->attach($observer);
$hawk = new Hawk_LixiServiceClient($request, $endpoint);
try {
    $hawk->quote('<?xml version="1.0" encoding="utf-8"?><!--Generated ValEx XML Valuation Transaction--> <!--$Id: LIXI_Common.php 82861 2013-03-04 21:40:06Z vpurohit $--> <ValuationTransaction ProductionData="No"><RevisionNumber LIXIVersion="1.4" LenderVersion="1.0" UserVersion="1.0" UserType="Valuer"></RevisionNumber><Identifier UniqueID="VXJ-000000549644" Type="VPMAssigned" Description="Valex Reference Number"></Identifier><Identifier UniqueID="N/A" Type="LenderAssigned"></Identifier><Date>2013-06-03</Date><Time>15:10:43+09:30</Time><Publisher><RelatedEntityRef RelatedID="VXV-000001"></RelatedEntityRef></Publisher><Audience><RelatedEntityRef RelatedID="VXV-000021"></RelatedEntityRef></Audience><Message><Identifier UniqueID="Dummy_Value" Type="VPMAssigned"></Identifier><MessageRelatesTo><Identifier UniqueID="VXJ-000000549644" Type="VPMAssigned"></Identifier><Identifier UniqueID="N/A" Type="LenderAssigned"></Identifier></MessageRelatesTo><MessageBody Type="Information"><Status Name="Initial"><Date>2013-06-03</Date><Time>15:40:43+10:00</Time></Status></MessageBody><ValuationType><Identifier UniqueID="Dummy_Value" Type="ValuerAssigned"></Identifier><FullRegistered InterestInProperty="Other" ValSubType="ShortForm"><SubTypeNote>API PropertyPro Report</SubTypeNote><RealEstate Status="Established" Construction="No" MortgageInsurance="No" Occupancy="OwnerPrimary" LandAreaHectares="0" Transaction="Refinancing"><Identifier UniqueID="12345" Type="VPMAssigned" Description="RP ID"></Identifier><Residential Type="FullyDetachedHouse"></Residential><EstimatedValue EstimateBasis="ApplicantEstimate">3075417</EstimatedValue><Location><Address><BuildingName></BuildingName><FloorNo></FloorNo><UnitNo></UnitNo><StreetNo>139</StreetNo><Street Type="Street">Brisbane</Street><City>BULIMBA</City><State Name="QLD"></State><Postcode>4171</Postcode><Country>AU</Country></Address><Title IsPrimaryTitle="Yes"></Title></Location></RealEstate><RequestDate><Date>2013-06-03</Date></RequestDate><DetailedComment><RelatedEntityRef RelatedID="Dummy_value"></RelatedEntityRef><Comment></Comment></DetailedComment><RequestedPriority Indicator="Normal"><Date>2013-06-05</Date><Time>15:10:22</Time></RequestedPriority><FeeSegment><Fee Amount="200.00" Description="PanelFee" Class="Valuer"><Identifier UniqueID="dummy_value" Type="VPMAssigned" Description="InvoiceNumber"></Identifier></Fee></FeeSegment><ResponseSupportingDoc DocAttached="No" RequestorToSight="No" DocType="Report"><Identifier UniqueID="VXDR-000000" Type="VPMAssigned"></Identifier></ResponseSupportingDoc><RiskAnalysis><RiskRating RatingType="Other" Rating="0-NotKnown"><Identifier UniqueID="ExtendedSellingPeriod" Type="VPMAssigned" Description="There are adverse marketability issues, that may require an extended selling period of more than 6 months."></Identifier><Comment></Comment></RiskRating><RiskRating RatingType="Other" Rating="0-NotKnown"><Identifier UniqueID="HighRiskOrNonResiPropType" Type="VPMAssigned" Description="The subject property comprises a higher risk or non residential property type."></Identifier><Comment></Comment></RiskRating><RiskRating RatingType="Other" Rating="0-NotKnown"><Identifier UniqueID="ExistingImprovements" Type="VPMAssigned" Description="There are essential repairs, incomplete works to the property and/or the property is currently under construction"></Identifier><Comment></Comment></RiskRating><RiskRating RatingType="Other" Rating="0-NotKnown"><Identifier UniqueID="HeritageLocationEnvironmental" Type="VPMAssigned" Description="Heritage, Location or Environmental Issues"></Identifier><Comment></Comment></RiskRating></RiskAnalysis><ValueComponent LandValue="0" ImprovementsValue="0" RecommendedSecurity="Yes" LikelyWeeklyUnfRental="0"><MarketValueAsIfComplete Type="SinglePoint" ValueFloor="0" ValueCeiling="0"><Description>Existing Property</Description></MarketValueAsIfComplete><EstimatedSettlement><Duration Units="Months"></Duration></EstimatedSettlement><Comment>Value Component</Comment><ExpectedSellingPeriodComment></ExpectedSellingPeriodComment></ValueComponent><SiteDetailResponse TitleSearched="No"><SiteArea></SiteArea><Neighbourhood></Neighbourhood><PropertyCharacteristics CurrentUse="Non-Residential" ExternalCondition="Unknown" InternalCondition="Unknown" InternalLayout="Unknown" MainBuilding="Yes" MineSubsidence="Yes" PCItems="" SiteArea="" StreetAppeal="Unknown"></PropertyCharacteristics></SiteDetailResponse></FullRegistered></ValuationType></Message><RelatedPartySegment><RelatedParty RelPartyType="ValuationPanelManager"><Identifier UniqueID="VXV-000001" Type="VPMAssigned"></Identifier><CompanyName BusinessName="Valuation Exchange"></CompanyName><Address><BuildingName>Workcover</BuildingName><FloorNo>11</FloorNo><UnitNo></UnitNo><StreetNo>100</StreetNo><Street Type="Street">Waymouth</Street><City>ADELAIDE</City><State Name="SA"></State><Postcode>5000</Postcode><Country>AU</Country></Address><WorkPhone><Phone><Fax></Fax></Phone><Phone><FixedPhone AreaCode="08">83735522</FixedPhone></Phone></WorkPhone><Email Type="Work">valuationplacement@valex.com.au</Email></RelatedParty><RelatedParty RelPartyType="ValuationFirm"><Identifier UniqueID="VXV-000021" Type="VPMAssigned"></Identifier><CompanyName BusinessName="Herron Todd White (Tasmania) Pty Ltd"></CompanyName><Address><BuildingName></BuildingName><FloorNo></FloorNo><UnitNo>Suite 2</UnitNo><StreetNo>23</StreetNo><Street Type="Street">Brisbane</Street><City>LAUNCESTON</City><State Name="TAS"></State><Postcode>7250</Postcode><Country>AU</Country></Address><WorkPhone><Phone><Fax AreaCode="03">63313392</Fax></Phone><Phone><FixedPhone AreaCode="03">63344997</FixedPhone></Phone></WorkPhone><Email Type="Work">admin.tasmania@htw.com.au</Email></RelatedParty><RelatedParty RelPartyType="Lender" RelPartyDescription="Commonwealth Bank of Australia Limited."><Identifier UniqueID="VXCL-008694" Type="VPMAssigned"></Identifier><CompanyName BusinessName="Commonwealth Bank of Australia"></CompanyName><PersonName><FirstName>Trevor</FirstName><Surname>Kay</Surname></PersonName><Address><BuildingName></BuildingName><FloorNo></FloorNo><UnitNo></UnitNo><StreetNo>48</StreetNo><Street Type="Place">Martin</Street><City>SYDNEY</City><State Name="NSW"></State><Postcode>2000</Postcode><Country>AU</Country></Address><WorkPhone><Phone><Fax AreaCode="02">83312547</Fax></Phone><Phone><FixedPhone>1300660052</FixedPhone></Phone></WorkPhone></RelatedParty><RelatedParty RelPartyType="Other" RelPartyDescription="Applicant"><Identifier UniqueID="VXC-0001247074" Type="VPMAssigned"></Identifier><PersonName><FirstName>Nigel</FirstName><Surname>Black</Surname></PersonName></RelatedParty><RelatedParty RelPartyType="Other" RelPartyDescription="Access Provider"><Identifier UniqueID="VXC-0001247075" Type="VPMAssigned"></Identifier><PersonName><FirstName>TR</FirstName><Surname>Resources Des</Surname></PersonName><WorkPhone><Phone><FixedPhone></FixedPhone></Phone><Phone><Fax></Fax></Phone></WorkPhone><HomePhone><Phone><FixedPhone>0412345678</FixedPhone></Phone><Phone><Mobile></Mobile></Phone></HomePhone></RelatedParty></RelatedPartySegment><vx:Job xmlns:vx="https://vx.valex.com.au/lixi/schema/vx/0.1/#" Purpose="Mortgage"><vx:Property Type="Dwelling"/></vx:Job></ValuationTransaction>');
} catch (Exception $e) {
    print_r($e->getMessage());
}
// print $hawk->__getLastRequest() . "\n\n";
// print $hawk->__getLastResponse() . "\n\n";
// print $hawk->__getLastRequestHeaders() . "\n\n";
// print $hawk->__getLastResponseHeaders() . "\n\n";
// $hawk->cancel("<xml>Hi</xml>");
// $hawk->quote("<xml>Hi</xml>");
// $hawk->update("<xml>Hi</xml>");