public static function setUpBeforeClass() { self::$client = new Client(); $contactsStream = Stream::factory(JsonLoader::getContactsJson()); $contactsNoNextStream = Stream::factory(JsonLoader::getContactsNoNextJson()); $contactStream = Stream::factory(JsonLoader::getContactJson()); $mock = new Mock([new Response(200, array(), $contactsStream), new Response(200, array(), $contactsNoNextStream), new Response(200, array(), $contactStream), new Response(201, array(), $contactStream), new Response(204, array()), new Response(400, array()), new Response(200, array(), $contactStream)]); self::$client->getEmitter()->attach($mock); }
public function testGetContactsNoNextLink() { $curlResponse = CurlResponse::create(JsonLoader::getContactsNoNextJson(), array('http_code' => 200)); $this->restClient->expects($this->once())->method('get')->with()->will($this->returnValue($curlResponse)); $response = $this->contactService->getContacts('access_token', array('limit' => 2)); $this->assertInstanceOf("Ctct\\Components\\ResultSet", $response); $contact = $response->results[1]; $this->assertInstanceOf("Ctct\\Components\\Contacts\\Contact", $contact); $this->assertEquals($response->next, null); $this->assertEquals(231, $contact->id); $this->assertEquals("ACTIVE", $contact->status); $this->assertEquals("", $contact->fax); $this->assertEquals("", $contact->prefix_name); $this->assertEquals("Jimmy", $contact->first_name); $this->assertEquals("", $contact->middle_name); $this->assertEquals("Roving", $contact->last_name); $this->assertEquals("Bear Tamer", $contact->job_title); $this->assertEquals("Animal Trainer Pro", $contact->company_name); $this->assertEquals("details", $contact->source_details); $this->assertEquals(false, $contact->confirmed); $this->assertEquals("", $contact->source); // custom fields $this->assertInstanceOf("Ctct\\Components\\Contacts\\CustomField", $contact->custom_fields[0]); $this->assertEquals("CustomField1", $contact->custom_fields[0]->name); $this->assertEquals("1", $contact->custom_fields[0]->value); //addresses $this->assertInstanceOf("Ctct\\Components\\Contacts\\Address", $contact->addresses[0]); $this->assertEquals("Suite 101", $contact->addresses[0]->line1); $this->assertEquals("line2", $contact->addresses[0]->line2); $this->assertEquals("line3", $contact->addresses[0]->line3); $this->assertEquals("Brookfield", $contact->addresses[0]->city); $this->assertEquals("PERSONAL", $contact->addresses[0]->address_type); $this->assertEquals("WI", $contact->addresses[0]->state_code); $this->assertEquals("us", $contact->addresses[0]->country_code); $this->assertEquals("53027", $contact->addresses[0]->postal_code); $this->assertEquals("", $contact->addresses[0]->sub_postal_code); //notes $this->assertEquals(0, count($contact->notes)); //lists $this->assertInstanceOf("Ctct\\Components\\Contacts\\ContactList", $contact->lists[0]); $this->assertEquals(1, $contact->lists[0]->id); $this->assertEquals("ACTIVE", $contact->lists[0]->status); // EmailAddress $this->assertInstanceOf("Ctct\\Components\\Contacts\\EmailAddress", $contact->email_addresses[0]); $this->assertEquals("ACTIVE", $contact->email_addresses[0]->status); $this->assertEquals("NO_CONFIRMATION_REQUIRED", $contact->email_addresses[0]->confirm_status); $this->assertEquals("ACTION_BY_OWNER", $contact->email_addresses[0]->opt_in_source); $this->assertEquals("2012-06-22T10:29:09.976Z", $contact->email_addresses[0]->opt_in_date); $this->assertEquals("", $contact->email_addresses[0]->opt_out_date); $this->assertEquals("*****@*****.**", $contact->email_addresses[0]->email_address); }