public function testAdd_element() { $collection = new Bridge_Api_ContainerCollection(); $i = 0; while ($i < 5) { $container = $this->getMock("Bridge_Api_ContainerInterface"); $collection->add_element(new $container()); $i++; } $this->assertEquals(5, sizeof($collection->get_elements())); }
/** * * @param type $object * @param type $offset_start * @param type $quantity */ public function list_containers($object, $offset_start = 0, $quantity = 10) { switch ($object) { case self::CONTAINER_TYPE_PHOTOSET: $params = []; if ($quantity) { $params['per_page'] = $quantity; } $params['page'] = $quantity != 0 ? floor($offset_start / $quantity) + 1 : 1; $params['user_id'] = $user_id = $this->get_user_id(); $response = $this->_api->executeMethod('flickr.photosets.getList', $params); if (!$response->isOk()) { throw new Bridge_Exception_ApiConnectorRequestFailed('Unable to retrieve container list ' . $object); } $photosets = new Bridge_Api_ContainerCollection(); $xml = $response->getXml(); $photosets->set_current_page((int) $xml->photosets['page'])->set_items_per_page((int) $xml->photosets['perpage'])->set_total_items((int) $xml->photosets['total'])->set_total_page((int) $xml->photosets['pages']); foreach ($xml->photosets->children() as $child) { $primary_photo = $this->get_element_from_id((string) $child['primary'], self::ELEMENT_TYPE_PHOTO); $photosets->add_element(new Bridge_Api_Flickr_Container($child, $user_id, $object, $primary_photo->get_thumbnail())); } $photosets->set_total_items(count($photosets->get_elements())); return $photosets; break; default: throw new Bridge_Exception_ObjectUnknown('Unknown object ' . $object); break; } }