/** * @{inheritDoc} */ public function getCustomers() { if (null === ($customers = json_decode($this->json, true))) { throw new \UnexpectedValueException('Failed to decode the provided JSON.'); } $domainCustomers = []; foreach ($customers as $customer) { if (!$this->isCustomerValid($customer)) { throw new \DomainException('There was an invalid customer entry in your JSON.'); } $domainCustomer = new Customer(); $domainCustomer->setUserId($customer['user_id'])->setName($customer['name'])->setLongitude($customer['longitude'])->setLatitude($customer['latitude']); $domainCustomers[] = $domainCustomer; } return $domainCustomers; }
public function testSetUserIdInvalid() { $this->setExpectedException('\\InvalidArgumentException'); $customer = new Customer(); $customer->setUserId('invalid'); }