Example #1
0
 public function testPopulate()
 {
     $subCategory = new Subcategory();
     $subCategory->setId(1234);
     $subCategory->setName("Self Service");
     $category = new Category();
     $category->setId(12);
     $category->setName("Restaurantes");
     $category->setSubCategory($subCategory);
     $city = new City();
     $city->setCountry("Brasil");
     $city->setState("SP");
     $city->setName("São Paulo");
     $address = new Address();
     $address->setCity($city);
     $address->setComplement("1 Andar");
     $address->setDistrict("Vila Olímpia");
     $address->setNumber("129");
     $address->setStreet("Rua Funchal");
     $address->setZipcode("04551-069");
     $gasStation = new GasStation(array('price_gas' => 1, 23, 'price_vodka' => 23, 45));
     $placeInfo = new PlaceInfo();
     $placeInfo->setGasStation($gasStation);
     $data = new \stdClass();
     $data->id = 123;
     $data->name = "Chegamos!";
     $data->average_rating = 4;
     $data->review_count = 3;
     $data->category = $category;
     $data->subcategory = $subCategory;
     $data->address = $address;
     $data->point->lat = "-23.529366";
     $data->point->lng = "-47.467117";
     $data->main_url = "http://chegamos.com/";
     $data->other_url = "http://chegamos.com.br/";
     $data->icon_url = "http://chegamos.com/img/icon.png";
     $data->description = "Description";
     $data->created = "01/12/2010 16:19";
     $data->phone = "11 2222-3333";
     $data->extended = $placeInfo;
     $data->num_visitors = 1024;
     $data->num_photos = 5;
     $this->object->populate($data);
     $this->assertEquals(123, $this->object->getId());
     $this->assertEquals("Chegamos!", $this->object->getName());
     $this->assertEquals(4, $this->object->getAverageRating());
     $this->assertEquals("Bom", $this->object->getAverageRatingString());
     $this->assertEquals(3, $this->object->getReviewCount());
     $this->assertEquals("app\\models\\Category", \get_class((object) $this->object->getCategory()));
     $this->assertEquals("Restaurantes - Self Service", (string) $this->object->getCategory());
     $this->assertEquals("app\\models\\Address", \get_class((object) $this->object->getAddress()));
     $this->assertEquals("Rua Funchal, 129 - Vila Olímpia<br/>São Paulo - SP", (string) $this->object->getAddress());
     $this->assertEquals("-23.529366,-47.467117", (string) $this->object->getPoint());
     $this->assertEquals("http://chegamos.com/", $this->object->getMainUrl());
     $this->assertEquals("http://chegamos.com.br/", $this->object->getOtherUrl());
     $this->assertEquals("http://chegamos.com/img/icon.png", $this->object->getIconUrl());
     $this->assertEquals("Description", $this->object->getDescription());
     $this->assertEquals("01/12/2010 16:19", $this->object->getCreated());
     $this->assertEquals("11 2222-3333", $this->object->getPhone());
     $this->assertEquals("app\\models\\PlaceInfo", \get_class((object) $this->object->getPlaceInfo()));
     $this->assertEquals(1024, $this->object->getNumVisitors());
     $this->assertEquals(5, $this->object->getNumPhotos());
 }