public function test_getSale() { $url = 'https://api.gilt.com/v1/sales/men/sunglasses-shop-312/detail.json?apikey=test_api_key'; $response = file_get_contents('test/data/sale_detail.json'); $http_get = $this->getMockHttpGetOnce($url, $response); $gilt = new Gilt('test_api_key', $http_get); $sale = $gilt->getSale('men', 'sunglasses-shop-312'); $this->assertEquals('Sunglasses Shop', $sale->getName()); $this->assertEquals('https://api.gilt.com/v1/sales/men/sunglasses-shop-312/detail.json', $sale->getSale()); $this->assertEquals('sunglasses-shop-312', $sale->getSaleKey()); $this->assertEquals('men', $sale->getStore()); $this->assertEquals('Spring’s right around the corner — and summer not long after that — which means now’s the perfect time to invest in a pair of great sunglasses. Luckily for you, we’ve compiled this collection of stylish shades by Oliver Peoples, Linda Farrow, Garrett Leight, and a host of others. Stock up, and get ready for the season ahead. ', $sale->getDescription()); $this->assertEquals('http://www.gilt.com/sale/men/sunglasses-shop-312?utm_medium=api&utm_campaign=bagspotting.com&utm_source=salesapi', $sale->getSaleUrl()); $this->assertEquals('2012-02-21T17:00:00Z', $sale->getBegins()); $this->assertEquals('2012-02-23T05:00:00Z', $sale->getEnds()); $imageUrls = $sale->getImageUrls(); $this->assertEquals(6, count($imageUrls)); foreach ($imageUrls as $key => $image_url) { $this->assertEquals($key, $image_url->getWidth() . 'x' . $image_url->getHeight()); $this->assertEquals(1, preg_match('#http://cdn1.gilt.com/images/share/uploads/\\d+/\\d+/\\d+/\\d+/orig.jpg#', $image_url->getUrl())); } $products = $sale->getProducts(); $this->assertEquals(93, count($products)); foreach ($products as $product_url) { $this->assertEquals(1, preg_match('#https://api.gilt.com/v1/products/\\d+/detail.json#', $product_url)); } }