/** * @dataProvider dataAbandoned * * @param bool|string $abandoned * @param string $expected */ public function testAbandoned($abandoned, $expected) { $webBuilder = new WebBuilder(new NullOutput(), vfsStream::url('build'), [], false); $webBuilder->setRootPackage($this->rootPackage); $this->package->setAbandoned($abandoned); $webBuilder->dump([$this->package]); $html = $this->root->getChild('build/index.html')->getContent(); $this->assertRegExp('/Package is abandoned, you should avoid using it/', $html); $this->assertRegExp($expected, $html); }
/** * Filter the package to add dist and other meta information. */ function filterPackage(CompletePackage $package) { list($vendor, $shortName) = explode('/', $package->getName()); // try to get the plugin info - may return an array or null/false try { $info = $this->getPluginInfo($shortName); } catch (RuntimeException $e) { if ($io->isVerbose()) { $io->writeError($e->getMessage()); } // this allows us to try again for this plugin return; } if ($info) { // set the dist info $package->setDistType('zip'); // strip out "tags", "trunk", slashes, and spaces $version = preg_replace('/tags|trunk|[\\/ ]/', '', $package->getSourceReference()); // if there is a version identifier, prepend with a period $version = $version ? ".{$version}" : ''; // set the dist url $package->setDistUrl('https://downloads.wordpress.org/plugin/' . urlencode($shortName . $version) . '.zip'); // set some additional meta info // this is inconsequential to the solver, but it gets stored in composer.lock // and appears when running `composer show vendor/package` if (isset($info['short_description'])) { $package->setDescription($info['short_description']); } if (!empty($info['contributors'])) { $authors = []; foreach ($info['contributors'] as $name => $homepage) { $authors[] = ['name' => $name, 'homepage' => $homepage]; } $package->setAuthors($authors); } if (!empty($info['tags'])) { $package->setKeywords($info['tags']); } // URL-ready slug $pluginSlug = urlencode($shortName); $package->setSupport(['forum' => "https://wordpress.org/support/plugin/{$pluginSlug}/", 'source' => "http://plugins.trac.wordpress.org/browser/{$pluginSlug}/", 'docs' => "https://wordpress.org/plugins/{$pluginSlug}/"]); $package->setHomepage("https://wordpress.org/plugins/{$pluginSlug}/"); } else { // null means the package is no longer active $package->setAbandoned(true); } }
/** * Filter the package to add dist and other meta information. */ function filterPackage(CompletePackage $package) { list($vendor, $shortName) = explode('/', $package->getName()); if (($themeInfo = $this->getThemeInfo()) && isset($themeInfo[$shortName])) { $info = $themeInfo[$shortName]; // set the dist info $package->setDistType('zip'); $package->setDistUrl($info['download_uri']); // additional meta info $package->setDescription($info['description']); $package->setAuthors([['name' => $info['author'], 'homepage' => $info['author_uri']]]); $package->setHomepage($info['theme_uri']); // is this theme retired? if (in_array($shortName, $this->getRetiredThemes())) { $package->setAbandoned(true); } } }
/** * @return array */ public function dataSetSelectedAsAbandoned() { $package = new CompletePackage('vendor/name', '1.0.0.0', '1.0'); $packageAbandoned1 = new CompletePackage('vendor/name', '1.0.0.0', '1.0'); $packageAbandoned1->setAbandoned(true); $packageAbandoned2 = new CompletePackage('vendor/name', '1.0.0.0', '1.0'); $packageAbandoned2->setAbandoned('othervendor/othername'); $data = []; $data['Nothing Abandonned'] = [[$package->getUniqueName() => $package], []]; $data['Package Abandonned without Replacement'] = [[$package->getUniqueName() => $packageAbandoned1], ['vendor/name' => true]]; $data['Package Abandonned with Replacement'] = [[$package->getUniqueName() => $packageAbandoned2], ['vendor/name' => 'othervendor/othername']]; return $data; }
public function dataSetSelectedAsAbandoned() { $package = new CompletePackage('vendor/name', '1.0.0.0', '1.0'); $packageAbandoned1 = new CompletePackage('vendor/name', '1.0.0.0', '1.0'); $packageAbandoned1->setAbandoned(true); $packageAbandoned2 = new CompletePackage('vendor/name', '1.0.0.0', '1.0'); $packageAbandoned2->setAbandoned('othervendor/othername'); $data = array(); $data['Nothing Abandonned'] = array(array($package->getUniqueName() => $package), array()); $data['Package Abandonned without Replacement'] = array(array($package->getUniqueName() => $packageAbandoned1), array('vendor/name' => true)); $data['Package Abandonned with Replacement'] = array(array($package->getUniqueName() => $packageAbandoned2), array('vendor/name' => 'othervendor/othername')); return $data; }