public function assertModelMatchesConfiguration(ModelInterface $person_list, $configuration = array()) { if (empty($configuration)) { $configuration = $this->configuration; } $person = PersonReferenceModel::create($configuration['person']); $this->assertEquals($person, $person_list->person); $list = ListReferenceModel::create($configuration['list']); $this->assertEquals($list, $person_list->list); $this->assertFalse($person_list->alreadyMember); }
public function testAddPersonToList() { $container = $responses = []; $responses[] = new Response(200, [], json_encode($this->responseAddListPerson)); $list_manager = $this->getListService($container, $responses); $list = new ListModel($this->responseListZero); $person = PersonModel::create(['$first_name' => 'George', 'Birthday' => '02/22/1732', '$email' => '*****@*****.**']); $person_list = $list_manager->addPersonToList($list, $person); $this->assertTrue($person_list instanceof PersonListModel, 'The returned object should be an instance of PersonListModel.'); $person_reference = PersonReferenceModel::create($this->responseAddListPerson['person']); $this->assertEquals($person_reference, $person_list->person); $list_reference = ListReferenceModel::create($this->responseAddListPerson['list']); $this->assertEquals($list_reference, $person_list->list); $this->assertTrue($person_list->alreadyMember); $request = $container[0]['request']; $this->assertSame('POST', $request->getMethod()); $fields = []; parse_str(urldecode((string) $request->getBody()), $fields); $this->assertSame('*****@*****.**', $fields['email']); $this->assertEquals($person, PersonModel::createFromJson($fields['properties'])); $this->assertTrue((bool) $fields['confirm_optin']); }