public function testMapToCustomClass() { $albumClass = 'Mechpave\\ImgurClient\\Tests\\Entity\\CustomAlbum'; $objectMapper = $this->getMockBuilder('Mechpave\\ImgurClient\\Mapper\\ObjectMapper')->disableOriginalConstructor()->getMock(); $objectMapper->expects($this->once())->method('getAlbumClass')->willReturn($albumClass); $insertedIntoGallery = new \DateTime(); $insertedIntoGallery->setTimestamp((int) $this->albumData['datetime']); $imageMapper = new ImageMapper($objectMapper); $albumMapper = new AlbumMapper($objectMapper, $imageMapper); $album = $albumMapper->buildAlbum($this->albumData); $this->assertTrue($album instanceof $albumClass); $this->assertEquals($album->getAlbumId(), $this->albumData['id']); $this->assertEquals($album->getTitle(), $this->albumData['title']); $this->assertEquals($album->getDescription(), $this->albumData['description']); $this->assertEquals($album->getInsertedIntoGallery(), $insertedIntoGallery); $this->assertEquals($album->getCover(), $this->albumData['cover']); $this->assertEquals($album->getCoverWidth(), $this->albumData['cover_width']); $this->assertEquals($album->getCoverHeight(), $this->albumData['cover_height']); $this->assertEquals($album->getAccountUsername(), $this->albumData['account_url']); $this->assertEquals($album->getAccountId(), $this->albumData['account_id']); $this->assertEquals($album->getPrivacy(), $this->albumData['privacy']); $this->assertEquals($album->getLayout(), $this->albumData['layout']); $this->assertEquals($album->getViews(), $this->albumData['views']); $this->assertEquals($album->getLink(), $this->albumData['link']); $this->assertEquals($album->isFavorite(), $this->albumData['favorite']); $this->assertEquals($album->isNsfw(), $this->albumData['nsfw']); $this->assertEquals($album->getSection(), $this->albumData['section']); $this->assertEquals($album->getOrder(), $this->albumData['order']); $this->assertEquals($album->getDeleteHash(), $this->albumData['deletehash']); $this->assertEquals($album->getImagesCount(), $this->albumData['images_count']); }
/** * Create a new album * * @param array $ids Ids of the images you want to add to the album * @param string $title * @param string $description * @param string $privacy * @param string $layout * @param string $cover * @return AlbumInterface */ public function create($ids = [], $title = null, $description = null, $privacy = null, $layout = null, $cover = null) { $postData = []; if (!empty($ids)) { $postData['ids'] = implode(',', $ids); } if ($title) { $postData['title'] = $title; } if ($description) { $postData['description'] = $description; } if ($privacy) { $postData['privacy'] = $privacy; } if ($layout) { $postData['layout'] = $layout; } if ($cover) { $postData['cover'] = $cover; } $response = $this->httpClient->post('album', $postData); $album = $this->albumMapper->buildAlbum($response->getBody()['data']); $album->setTitle($title); $album->setDescription($description); $album->setPrivacy($privacy); $album->setLayout($layout); $album->setCover($cover); return $album; }