/** * Create a new organizer in the specified group. * * @param int $groupKey * @param Organizer $organizer * @return Organizer with organizer key specified */ public function createOrganizer($groupKey, Organizer $organizer) { $url = "{$this->endpoint}/{$groupKey}/organizers"; $jsonBody = $this->client->sendRequest('POST', $url, null, false, $organizer->toArrayForApi()); $organizer->setOrganizerKey($jsonBody); return $organizer; }
/** * @dataProvider createOrganizer */ public function testCreateOrganizer($groupKey, Organizer $organizer, $response) { $client = $this->getMockBuilder('Client')->setMethods(array('sendRequest'))->getMock(); $client->method('sendRequest')->will($this->returnValue($response)); $client->expects($this->once())->method('sendRequest')->with($this->equalTo('POST'), $this->logicalAnd($this->stringStartsWith('groups'), $this->stringEndsWith('organizers')), null, false, $organizer->toArrayForApi()); $organizerService = new OrganizerService($client); $actualOrganizer = $organizerService->createOrganizer($groupKey, $organizer); $this->assertNotNull($actualOrganizer); $this->assertAttributeEquals($response, 'organizerKey', $actualOrganizer); }