public function testPostDataPriceNamesAndValues() { $event = new CultureFeed_Uitpas_Event_CultureEvent(); $event->postPriceNames = array('price 1', 'price 2'); $event->postPriceValues = array(10.5, 11.6); $postData = $event->toPostData(); $this->assertArraySubset(array('price.name.1' => 'price 1', 'price.value.1' => 10.5, 'price.name.2' => 'price 2', 'price.value.2' => 11.6), $postData); }
/** * Test the registering of an event. */ public function testRegisterEvent() { $response = <<<XML <?xml version="1.0" encoding="utf-8" ?> <response> <code>1</code> <message>foo</message> </response> XML; /* @var $oauth_client_stub PHPUnit_Framework_MockObject_MockObject */ $oauth_client_stub = $this->getMock('CultureFeed_OAuthClient'); $oauth_client_stub->expects($this->once())->method('consumerPostAsXml')->with($this->equalTo('uitpas/cultureevent/register'))->will($this->returnValue($response)); $event_xml_str = file_get_contents(dirname(__FILE__) . self::EVENTXML); $event_xml_obj = new CultureFeed_SimpleXMLElement($event_xml_str); $event = CultureFeed_Uitpas_Event_CultureEvent::createFromXML($event_xml_obj); $this->assertInstanceOf('CultureFeed_Uitpas_Event_CultureEvent', $event); $this->assertEquals("9ba1b072-40ea-41b6-a66b-ac3fdf646f36", $event->cdbid); $this->assertEquals("5C9C73D3-E82F-E7B3-44161E6E3802E64F", $event->locationId); $cf = new CultureFeed($oauth_client_stub); $response = $cf->uitpas()->registerEvent($event); $this->assertInstanceOf('\\CultureFeed_Uitpas_Response', $response); $this->assertEquals(1, $response->code); $this->assertEquals('foo', $response->message); }
/** * {@inheritdoc} */ public function searchEvents(CultureFeed_Uitpas_Event_Query_SearchEventsOptions $query) { $data = $query->toPostData(); //$data['email'] = "*****@*****.**"; $result = $this->oauth_client->consumerGetAsXml('uitpas/cultureevent/search', $data); //dpm( $data ); //dpm( $result ); try { $xml = new CultureFeed_SimpleXMLElement($result); } catch (Exception $e) { throw new CultureFeed_ParseException($result); } $events = array(); $objects = $xml->xpath('/cultureEvents/event'); $total = $xml->xpath_int('/cultureEvents/total'); foreach ($objects as $object) { $events[] = CultureFeed_Uitpas_Event_CultureEvent::createFromXML($object); } return new CultureFeed_ResultSet($total, $events); }
require_once $file; } spl_autoload_register('culturefeed_autoload'); try { // http://uitpas-acc.lodgon.com:8080/uitid/rest/ // 62510a93c4754ed7306113e0f2391c82 // beea3e641e184c4a4bf3272ef4dcedf7 $endpoint = $_SERVER['argv'][1]; $consumer_key = $_SERVER['argv'][2]; $consumer_secret = $_SERVER['argv'][3]; $oc = new CultureFeed_DefaultOAuthClient($consumer_key, $consumer_secret); $oc->setEndpoint($endpoint); $c = new CultureFeed($oc); $event_xml_str = file_get_contents(dirname(__FILE__) . "/../test/uitpas/data/events/event.xml"); $event_xml_obj = new CultureFeed_SimpleXMLElement($event_xml_str); $event = CultureFeed_Uitpas_Event_CultureEvent::createFromXML($event_xml_obj); $data = $event->toPostData(); var_dump($data); $data = $c->uitpas()->registerEvent($event); print_r($data); } catch (Exception $e) { $eol = PHP_EOL; $type = get_class($e); print "An exception of type {$type} was thrown." . PHP_EOL; print "Code: {$e->getCode()}" . PHP_EOL; if ($e instanceof CultureFeed_Exception) { print "CultureFeed error code: {$e->error_code}" . PHP_EOL; } print "Message: {$e->getMessage()}" . PHP_EOL; print "Stack trace: {$eol}{$e->getTraceAsString()}" . PHP_EOL; exit(1);