/** * @depends test_createComp */ public function test_createPhotos($photoComp) { $PhotoOfTheWeek = new PhotoOfTheWeek(); $PhotoOfTheWeek->getStartOfWeek(); $Exif = new Exif(); $i = 1; foreach ($this->ids as $id) { $User = $this->test_createUser(sprintf("username-%s", $id), sprintf("*****@*****.**", $id)); $Image = ImageFactory::CreateImage($id, "flickr", Images::OPT_REFRESH); $this->assertTrue($photoComp->canUserSubmitPhoto($User)); $this->assertFalse($photoComp->isImageInCompetition($Image)); $photoComp->submitPhoto($Image, $User); $this->assertFalse($photoComp->canUserSubmitPhoto($User)); $this->assertTrue($photoComp->isImageInCompetition($Image)); $this->assertEquals($User->id, $photoComp->getPhotoAuthor($Image)->id); $this->assertTrue($photoComp->isImageOwnedBy($User, $Image)); $photoComp->getNumVotesForUser($User); $this->assertEquals(1, $photoComp->getNumPendingSubmissions()); $photoComp->approveSubmission($Image); $photoComp->getPendingSubmissions(); $this->assertEquals(0, $photoComp->getNumPendingSubmissions()); $this->assertEquals(0, $photoComp->getNumVotesForImage($Image)); $photoComp->getPhotoContext($Image); $this->assertEquals(1, $photoComp->getPhoto($Image)->status); $this->assertEquals($i, count($photoComp->getPhotosAsArray(true))); $i++; $PhotoOfTheWeek->NominateImage($Image, new DateTime(), $User); $PhotoOfTheWeek->isPhotoOfTheWeek($Image); $exif = $Exif->getImageExif($Image, true); $exif = $Exif->formatExif($exif); } $PhotoOfTheWeek->getImageOfTheWeek(); $PhotoOfTheWeek->getPreviousPhotos(); $photoComp->getPendingSubmissions(); $this->assertEquals(0, $photoComp->getNumPendingSubmissions()); foreach ($this->ids as $id) { $Image = ImageFactory::CreateImage($id, "flickr"); $photoComp->rejectSubmission($Image); Debug::LogCLI("Rejected image " . $Image->id); break; } $photoComp->getArray(); $photoComp->getPhotosAsArray(); $photoComp->getPhotosAsArrayByVotes(); $photoComp->getSiteMessage(); $photoComp->getWinningPhoto(); return $photoComp; }
/** * Site content other than news that we could feature in this newsletter * @since Version 3.10.0 * @return \Railpage\Newsletters\Weekly */ private function getOtherContent() { $query = "SELECT CONCAT('http://railpage.com.au/locations/', LOWER(country), '/', LOWER(region_slug), '/', slug) AS url, name AS title, `desc` AS text, 'Locations' AS subtitle, `lat`, `long` AS lon FROM location WHERE date_added >= UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 WEEK)) LIMIT 0, 2"; $result = $this->db->fetchAll($query); foreach ($result as $key => $row) { if (!empty($row['lat']) && !empty($row['lon'])) { $row['featuredimage'] = MapImage::Image($row['lat'], $row['lon']); $row['url'] = NewsletterUtility::CreateUTMParametersForLink($this->Newsletter, $row['url']); } $result[$key] = $row; } // Get the photo of the week $PhotoOfTheWeek = new PhotoOfTheWeek(); $photo = $PhotoOfTheWeek->getImageOfTheWeek(); if (!empty($photo)) { $result[] = ["url" => NewsletterUtility::CreateUTMParametersForLink($this->Newsletter, $photo['url']['canonical']), "title" => "Photo of the week", "subtitle" => sprintf("%s by %s", $photo['title'], $photo['meta']['author']['realname']), "text" => "Each week our site staff scour the photos submitted to Railpage, and showcase the best as Photo of the Week. We have thousands of photos on Railpage - dive in and take a look!", "featuredimage" => $photo['meta']['sizes']['small']['source'], "link_text" => "View photo"]; } $this->prependedContent = $result; $this->num_items += count($this->prependedContent); return $this; }