public function testCreateServiceConsumer()
 {
     $oauth_client_stub = $this->getMock('CultureFeed_OAuthClient');
     $cf = new Culturefeed($oauth_client_stub);
     $consumerKey = 'y1j72kx0btua10otvftd25cf6mws39pg';
     $consumerSecret = 'o86hyiffn254i3v26o0pqiononc4yw0v';
     $callback = 'http://example.com/callback';
     $description = 'Consumer for Example Corp.';
     $logo = 'http://example.com/logo.png';
     $domain = 'example.com';
     $name = 'Example.com';
     $destinationAfterEmailVerification = 'http://example.com/after/verification/email';
     $empty_consumer_xml = file_get_contents(dirname(__FILE__) . '/data/consumer/empty_consumer.xml');
     $element = new SimpleXMLElement($empty_consumer_xml);
     $element->addChild('consumerKey', $consumerKey);
     $element->addChild('consumerSecret', $consumerSecret);
     $element->addChild('callback', $callback);
     $element->addChild('domain', $domain);
     $element->addChild('description', $description);
     $element->addChild('logo', $logo);
     $element->addChild('name', $name);
     $element->addChild('destinationAfterEmailVerification', $destinationAfterEmailVerification);
     $element->addChild('creationDate', '2011-10-09T16:00Z');
     $element->addChild('id', 27);
     $element->addChild('status', 'ACTIVE');
     $xml = $element->asXML();
     $oauth_client_stub->expects($this->once())->method('consumerPostAsXml')->with($this->equalTo('serviceconsumer'), $this->equalTo(array('consumerKey' => $consumerKey, 'consumerSecret' => $consumerSecret, 'callback' => $callback, 'domain' => $domain, 'description' => $description, 'logo' => $logo, 'name' => $name, 'destinationAfterEmailVerification' => $destinationAfterEmailVerification)))->will($this->returnValue($xml));
     $consumer = new CultureFeed_Consumer();
     $consumer->consumerKey = 'y1j72kx0btua10otvftd25cf6mws39pg';
     $consumer->consumerSecret = 'o86hyiffn254i3v26o0pqiononc4yw0v';
     $consumer->domain = $domain;
     $consumer->name = $name;
     $consumer->callback = $callback;
     $consumer->description = $description;
     $consumer->logo = $logo;
     $consumer->destinationAfterEmailVerification = "http://example.com/after/verification/email";
     // The following properties shouldn't be passed to the server, we add them so we can test
     // that they are not set in the new service consumer
     $consumer->id = 1;
     // 2011-10-09T14:00Z
     $consumer->creationDate = 1318168800;
     $consumer->status = 'BLOCKED';
     try {
         $new_consumer = $cf->createServiceConsumer($consumer);
     } catch (CultureFeed_HttpException $e) {
         $this->fail('CultureFeed::createServiceConsumer() failed, HTTP status ' . $e->getCode() . ', message: ' . $e->getMessage());
     }
     $this->assertInstanceOf('CultureFeed_Consumer', $new_consumer);
     $this->assertEquals($consumer->name, $new_consumer->name);
     $this->assertEquals($consumer->callback, $new_consumer->callback);
     $this->assertEquals($consumer->consumerKey, $new_consumer->consumerKey);
     $this->assertEquals($consumer->domain, $new_consumer->domain);
     $this->assertEquals($consumer->description, $new_consumer->description);
     $this->assertEquals($consumer->logo, $new_consumer->logo);
     $this->assertEquals($consumer->destinationAfterEmailVerification, $new_consumer->destinationAfterEmailVerification);
     // properties that differ
     // creationDate should be 2011-10-09T16:00Z as returned by the oauth_client
     $this->assertInternalType('integer', $new_consumer->creationDate);
     $this->assertEquals(1318176000, $new_consumer->creationDate);
     // id as returned by the oauth_client
     $this->assertInternalType('integer', $new_consumer->id);
     $this->assertEquals(27, $new_consumer->id);
     // status as returned by the oauth_client
     $this->assertEquals('ACTIVE', $new_consumer->status);
 }