/**
  * Test searching users.
  */
 public function testSearchUsers()
 {
     $query = new CultureFeed_SearchUsersQuery();
     $query->name = 'john';
     $query->mboxIncludePrivate = true;
     $search_users_xml = file_get_contents(dirname(__FILE__) . '/data/search_users.xml');
     $this->oauthClient->expects($this->once())->method('consumerGetAsXml')->with('user/search', array('name' => 'john', 'mboxIncludePrivate' => 'true'))->will($this->returnValue($search_users_xml));
     $johnDoe = new CultureFeed_SearchUser();
     $johnDoe->id = 'A5912755-8060-4CB7-B0D1-51717725A46A';
     $johnDoe->nick = 'john.doe';
     $johnDoe->mbox = '*****@*****.**';
     $johnDoe->depiction = '//media.uitid.be/fis/rest/download/ce126667652776f0e9e55160f12f5463/uiv/default.png';
     $johnDoe->sortValue = null;
     $johnySmith = new CultureFeed_SearchUser();
     $johnySmith->id = '0AC1C30A-4821-4D82-98AD-ADC02FBC0059';
     $johnySmith->nick = 'johny.smith';
     $johnySmith->mbox = '*****@*****.**';
     $johnySmith->depiction = '//media.uitid.be/fis/rest/download/ce126667652776f0e9e55160f12f5325/uiv/picture-5015.jpg';
     $johnySmith->sortValue = null;
     $expectedUsers = array($johnDoe, $johnySmith);
     $expectedResults = new CultureFeed_ResultSet(2, $expectedUsers);
     $actualResults = $this->cultureFeed->searchUsers($query);
     $this->assertEquals($expectedResults, $actualResults);
 }
 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);
 }