Skip to content
Permalink
Browse files

Updated to Porter 4.0 final parity.

  • Loading branch information...
Bilge committed Apr 10, 2018
1 parent f35ed8c commit f6b1c2e24ff29a0398b1e5aa4edd829397b10b11
@@ -10,15 +10,28 @@ php:
- 5.6
- 7.0
- 7.1
- 7.2

env:
matrix:
-
- DEPENDENCIES=--prefer-lowest

matrix:
fast_finish: true

cache:
directories:
- vendor

install:
- alias composer=composer\ -n && composer selfupdate
- composer validate
- composer --prefer-source install
- composer update --no-progress --no-suggest $DEPENDENCIES

script:
- bin/test --coverage-clover=build/logs/clover.xml
- composer test -- --coverage-clover=build/logs/clover.xml

after_success:
- composer --prefer-source require satooshi/php-coveralls
- vendor/bin/coveralls -v
- composer require php-coveralls/php-coveralls:^2
- vendor/bin/php-coveralls -v
@@ -9,10 +9,10 @@ IANA Provider

Provides [Internet Assigned Numbers Authority (IANA) ](http://iana.org) data for [Porter][Porter].

The following data is currently available.
The following resources are currently available.

- DNS root zones (assignments of ccTLDs and gTLDs).
- Transport protocol port number and service name registry.
- `IanaRootZones` – DNS root zones (assignments of ccTLDs and gTLDs).
- `IanaPortNumbers` – Transport protocol port number and service name registry.

Requirements
------------

This file was deleted.

@@ -8,12 +8,14 @@
}
],
"require": {
"scriptfusion/porter": "^1",
"scriptfusion/porter": "^4",
"connectors/http": "^2",
"league/csv": "^8",
"symfony/dom-crawler": "^3"
},
"require-dev": {
"phpunit/phpunit": "^4"
"phpunit/phpunit": "^4.8",
"mockery/mockery": "^0.9.4"
},
"autoload": {
"psr-4": {
@@ -24,5 +26,8 @@
"psr-4": {
"ScriptFUSIONTest\\Porter\\Provider\\Iana\\": "test"
}
},
"scripts": {
"test": "phpunit -c test"
}
}
@@ -3,13 +3,20 @@
use ScriptFUSION\Porter\Connector\Connector;
use ScriptFUSION\Porter\Net\Http\HttpConnector;
use ScriptFUSION\Porter\Provider\AbstractProvider;
use ScriptFUSION\Porter\Provider\Provider;
final class IanaProvider extends AbstractProvider
final class IanaProvider implements Provider
{
private $connector;
public function __construct(Connector $connector = null)
{
// The default HttpConnector should suffice.
parent::__construct($connector ?: new HttpConnector);
$this->connector = $connector ?: new HttpConnector;
}
public function getConnector()
{
return $this->connector;
}
}
@@ -2,19 +2,18 @@
namespace ScriptFUSION\Porter\Provider\Iana\Provider\Resource;
use League\Csv\Reader;
use ScriptFUSION\Porter\Connector\Connector;
use ScriptFUSION\Porter\Options\EncapsulatedOptions;
use ScriptFUSION\Porter\Connector\ImportConnector;
use ScriptFUSION\Porter\Provider\Iana\Provider\IanaProvider;
use ScriptFUSION\Porter\Provider\Resource\AbstractResource;
use ScriptFUSION\Porter\Provider\Resource\ProviderResource;
class IanaPortNumbers extends AbstractResource
class IanaPortNumbers implements ProviderResource
{
public function getProviderClassName()
{
return IanaProvider::class;
}
public function fetch(Connector $connector, EncapsulatedOptions $options = null)
public function fetch(ImportConnector $connector)
{
$csv = $connector->fetch(
'http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.csv'
@@ -2,24 +2,23 @@
namespace ScriptFUSION\Porter\Provider\Iana\Provider\Resource;
use ScriptFUSION\Porter\Collection\CountableProviderRecords;
use ScriptFUSION\Porter\Connector\Connector;
use ScriptFUSION\Porter\Options\EncapsulatedOptions;
use ScriptFUSION\Porter\Connector\ImportConnector;
use ScriptFUSION\Porter\Provider\Iana\Provider\IanaProvider;
use ScriptFUSION\Porter\Provider\Resource\AbstractResource;
use ScriptFUSION\Porter\Provider\Resource\ProviderResource;
use Symfony\Component\DomCrawler\Crawler;
class IanaRootZones extends AbstractResource
class IanaRootZones implements ProviderResource
{
public function getProviderClassName()
{
return IanaProvider::class;
}
public function fetch(Connector $connector, EncapsulatedOptions $options = null)
public function fetch(ImportConnector $connector)
{
$html = $connector->fetch('http://www.iana.org/domains/root/db');
$crawler = new Crawler($html);
$crawler = new Crawler("$html");
$tldTable = $crawler->filterXPath('//table[@id="tld-table"]');
$headers = $tldTable->filterXPath('./*/thead/tr/th')->extract('_text');
$cells = $tldTable->filterXPath('./*/tbody/tr/td')->extract('_text');
@@ -1,6 +1,7 @@
<?php
namespace ScriptFUSIONTest\Porter\Provider\Iana\Functional;
use Psr\Container\ContainerInterface;
use ScriptFUSION\Porter\Porter;
use ScriptFUSION\Porter\Provider\Iana\Provider\IanaProvider;
@@ -11,6 +12,15 @@ abstract class IanaTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
$this->porter = (new Porter)->registerProvider(new IanaProvider);
$this->porter = (new Porter(
\Mockery::mock(ContainerInterface::class)
->shouldReceive('has')
->with(IanaProvider::class)
->andReturn(true)
->shouldReceive('get')
->with(IanaProvider::class)
->andReturn(new IanaProvider)
->getMock()
));
}
}

0 comments on commit f6b1c2e

Please sign in to comment.
You can’t perform that action at this time.