/** * Update the stored database. * * @since 0.1.0 * * @param Event $event The event that has called the update method. */ public static function update(Event $event) { $dbFilename = PHPReleases::getLocation(); self::maybeCreateDBFolder(dirname($dbFilename)); $io = $event->getIO(); $io->write('Fetching change logs from official PHP website...', false); $io->write(' PHP5...', false); $php5 = self::downloadFile(self::PHP_5_RELEASES); $io->write(' PHP7...', false); $php7 = self::downloadFile(self::PHP_7_RELEASES); $io->write(' done!', true); $releases = array(); $io->write('Parsing change logs to extract versions...', false); $io->write(' PHP5...', false); $php5Releases = self::parseReleases($php5); $io->write('(' . count($php5Releases) . ' releases)', false); $releases = array_merge($releases, $php5Releases); $io->write(' PHP7...', false); $php7Releases = self::parseReleases($php7); $io->write('(' . count($php7Releases) . ' releases)', false); $releases = array_merge($releases, $php7Releases); $io->write(' done!', true); ksort($releases, SORT_NATURAL); self::generateConfig($releases, $dbFilename); $io->write('The PHP Releases database has been updated.', true); }
/** * Test getting the location of the releases DB. * * @since 0.1.0 * * @covers PHPReleases::getLocation */ public function testGetLocation() { $location = PHPReleases::getLocation(false); $this->assertInternalType('string', $location); $this->assertContains(PHPReleases::DB_FOLDER, $location); $locationArray = PHPReleases::getLocation(true); $this->assertInternalType('array', $locationArray); $this->assertArrayHasKey('folder', $locationArray); $this->assertArrayHasKey('file', $locationArray); $this->assertContains(PHPReleases::DB_FOLDER, $locationArray['folder']); $this->assertEquals(PHPReleases::DB_FILENAME, $locationArray['file']); }