public function testSubmitData() { $subscriber = new \StatusPage\SDK\Subscribers\Subscriber(); $subscriber->setEmail('*****@*****.**'); $subscriber->setPhoneCountry('RU'); $subscriber->setPhoneNumber('79120000000'); $this->clientMock->expects($this->once())->method('send')->with('subscribers.json', 'POST', array('Content-Type' => 'application/x-www-form-urlencoded'), array('subscriber' => array('email' => '*****@*****.**', 'phone_number' => '79120000000', 'phone_country' => 'RU'))); $this->endpoint->addSubscriber($subscriber); }
public function addSubscriber(Subscriber $subscriber) { $body = array(); $email = $subscriber->getEmail(); $phone = $subscriber->getPhoneNumber(); $country = $subscriber->getPhoneCountry(); if (!empty($email)) { $body['email'] = $email; } if (!empty($phone)) { $body['phone_number'] = $phone; } if (!empty($country)) { $body['phone_country'] = $country; } return $this->client->send('subscribers.json', 'POST', array('Content-Type' => 'application/x-www-form-urlencoded'), array('subscriber' => $body)); }