Skip to content

Commit

Permalink
- system test for all the scrapers
Browse files Browse the repository at this point in the history
  • Loading branch information
vantoozz committed May 5, 2020
1 parent 4c0707f commit e0a4030
Showing 1 changed file with 2 additions and 24 deletions.
26 changes: 2 additions & 24 deletions tests/systemTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
use hanneskod\classtools\Iterator\ClassIterator;
use Http\Adapter\Guzzle6\Client as HttpAdapter;
use Http\Message\MessageFactory\GuzzleMessageFactory as MessageFactory;
use ReflectionClass;
use Symfony\Component\Finder\Finder;
use Vantoozz\ProxyScraper\HttpClient\HttpClientInterface;
use Vantoozz\ProxyScraper\HttpClient\Psr18HttpClient;
use Vantoozz\ProxyScraper\Scrapers\Discoverable;
use Vantoozz\ProxyScraper\Scrapers\ScraperInterface;
use Vantoozz\ProxyScraper\SystemTests\ProxiesMiner\Cached;
use Vantoozz\ProxyScraper\SystemTests\Reports\CountsReport;
Expand All @@ -30,31 +29,10 @@
$miner = new ProxiesMiner\ScrapersProxiesMiner;

$classIterator = new ClassIterator((new Finder)->in(__DIR__ . '/../src/Scrapers'));
foreach ($classIterator->type(ScraperInterface::class) as $class) {
/** @var ReflectionClass $class */
foreach ($classIterator->type(Discoverable::class) as $class) {
if (!$class->isInstantiable()) {
continue;
}

$constructor = $class->getConstructor();
if (!$constructor) {
continue;
}

$parameters = $constructor->getParameters();
if (1 !== count($parameters)) {
continue;
}

$dependency = $parameters[0]->getClass();
if (!$dependency) {
continue;
}

if (!$dependency->implementsInterface(HttpClientInterface::class)) {
continue;
}

/** @var ScraperInterface $scraper */
$scraper = $class->newInstance($httpClient);
$miner->addScraper($scraper);
Expand Down

0 comments on commit e0a4030

Please sign in to comment.