Example #1
0
 public function testConfig()
 {
     $configArray = ['configKey' => 123, 'configValue' => 'Shorts'];
     $response_body = [$configArray];
     $this->responses = [new Response(200, [], json_encode($response_body)), new Response(200, [], json_encode($response_body)), new Response(200, [], json_encode($response_body)), new Response(200, [], json_encode($response_body)), new Response(200, [], json_encode($response_body))];
     // History that's going to be populated by the HTTP Client.
     $this->history = [];
     // Create httpClient
     $this->httpClient = $this->getHttpClient($this->history, $this->responses);
     // Create the client with responses.
     $this->ews = new EWSClient($this->httpClient, self::ACCESS_TOKEN);
     $event = new Event($this->ews, ['eventCode' => 'N15FA2']);
     $event->getConfigs();
     $configs = $event->getConfigs();
     $config = array_pop($configs);
     $this->assertSame($configArray, $config->asArray());
     $config->setConfigValue('Trousers');
     $configArray['configValue'] = 'Trousers';
     $this->assertSame($configArray, $config->asArray());
     $config->update();
     $this->assertSame($event, $config->getEvent());
     $config->setEvent($event);
     $this->assertSame($event, $config->getEvent());
     $new_config = new Config($this->ews, ['configKey' => 124, 'configValue' => 'Skirt'], $event);
     $new_config->create();
     $event->createOrUpdateConfig(123, 'Kilt');
     $event->createOrUpdateConfig(125, 'Shirt');
     $this->assertSame(3, count($event->getConfigs()));
     $event->setConfigs($configs);
 }