-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from SpazzMarticus/develop
Updated for PHP7.2
- Loading branch information
Showing
5 changed files
with
133 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,11 @@ | ||
language: php | ||
php: | ||
- 5.4 | ||
- 5.5 | ||
- 5.6 | ||
- hhvm | ||
- nightly | ||
- 7 | ||
|
||
before_install: | ||
- composer self-update | ||
install: | ||
- travis_retry composer install --no-interaction --prefer-source | ||
script: | ||
language: php | ||
php: | ||
- 7.2 | ||
- 7.3 | ||
|
||
before_install: | ||
- composer self-update | ||
install: | ||
- travis_retry composer install --no-interaction --prefer-source | ||
script: | ||
- vendor/bin/phpunit --configuration ./build/phpunitconfig.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,29 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.5/phpunit.xsd" | ||
backupGlobals="false" | ||
backupStaticAttributes="false" | ||
colors="true" | ||
verbose="true" | ||
beStrictAboutOutputDuringTests="true" | ||
beStrictAboutTestSize="true" | ||
beStrictAboutTestsThatDoNotTestAnything="true" | ||
beStrictAboutTodoAnnotatedTests="true" | ||
checkForUnintentionallyCoveredCode="true" | ||
bootstrap="../vendor/autoload.php" | ||
processIsolation="false" | ||
> | ||
<testsuites> | ||
<testsuite name="unit"> | ||
<directory suffix="Test.php">../tests/unit</directory> | ||
</testsuite> | ||
</testsuites> | ||
<filter> | ||
<whitelist> | ||
<directory suffix=".php">../src</directory> | ||
</whitelist> | ||
</filter> | ||
<logging> | ||
<log type="coverage-html" target="coverage/" higlight="true" showUncoveredFiles="true"></log> | ||
<log type="coverage-text" target="php://stdout" showUncoveredFiles="false" showOnlySummary="true"></log> | ||
</logging> | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.5/phpunit.xsd" | ||
backupGlobals="false" | ||
backupStaticAttributes="false" | ||
colors="true" | ||
verbose="true" | ||
beStrictAboutOutputDuringTests="true" | ||
beStrictAboutTestsThatDoNotTestAnything="true" | ||
beStrictAboutTodoAnnotatedTests="true" | ||
bootstrap="../vendor/autoload.php" | ||
processIsolation="false" | ||
> | ||
<testsuites> | ||
<testsuite name="unit"> | ||
<directory suffix="Test.php">../tests/unit</directory> | ||
</testsuite> | ||
</testsuites> | ||
<filter> | ||
<whitelist> | ||
<directory suffix=".php">../src</directory> | ||
</whitelist> | ||
</filter> | ||
<logging> | ||
<log type="coverage-html" target="coverage/" showUncoveredFiles="true"></log> | ||
<log type="coverage-text" target="php://stdout" showUncoveredFiles="false" showOnlySummary="true"></log> | ||
</logging> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,30 @@ | ||
{ | ||
"name": "spazzmarticus/e-css-tractor", | ||
"description": "Extracts CSS from HTML (Style-Tags)", | ||
"type": "library", | ||
"license":"MIT", | ||
"keywords": ["css", "extract", "stylesheet"], | ||
"authors": [ | ||
{ | ||
"name": "SpazzMarticus", | ||
"homepage": "https://github.com/SpazzMarticus" | ||
} | ||
], | ||
"autoload": { | ||
"psr-4": { | ||
"SpazzMarticus\\eCSStractor\\": "src/" | ||
}, | ||
"classmap": [ | ||
"src/" | ||
] | ||
}, | ||
"require": { | ||
"php": ">=5.4.0" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "*", | ||
"phpdocumentor/phpdocumentor": "*" | ||
}, | ||
"scripts": { | ||
"test": "phpunit -c build/phpunitconfig.xml", | ||
"doc": "phpdoc -c build/phpdocumentor.xml --template=\"xml\" --template=\"clean\"" | ||
} | ||
} | ||
{ | ||
"name": "spazzmarticus/e-css-tractor", | ||
"description": "Extracts CSS from HTML (Style-Tags)", | ||
"type": "library", | ||
"license":"MIT", | ||
"keywords": ["css", "extract", "stylesheet"], | ||
"authors": [ | ||
{ | ||
"name": "SpazzMarticus", | ||
"homepage": "https://github.com/SpazzMarticus" | ||
} | ||
], | ||
"autoload": { | ||
"psr-4": { | ||
"SpazzMarticus\\eCSStractor\\": "src/" | ||
}, | ||
"classmap": [ | ||
"src/" | ||
] | ||
}, | ||
"require": { | ||
"php": "^7.2" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^8.1" | ||
}, | ||
"scripts": { | ||
"test": "phpunit -c build/phpunitconfig.xml" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,58 @@ | ||
<?php | ||
|
||
namespace SpazzMarticus\eCSStractor; | ||
|
||
/** | ||
* @uses \SpazzMarticus\eCSStractor\eCSStractor | ||
*/ | ||
class eCSStractorTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
protected $_eCSStractor; | ||
|
||
protected function setUp() | ||
{ | ||
$this->_eCSStractor=new eCSStractor(); | ||
} | ||
|
||
/** | ||
* @dataProvider providerExtract | ||
* @covers \SpazzMarticus\eCSStractor\eCSStractor::extract | ||
*/ | ||
public function testExtract($html, $cssFormat) | ||
{ | ||
$this->assertStringMatchesFormat($cssFormat, $this->_eCSStractor->extract($html)); | ||
} | ||
|
||
public function providerExtract() | ||
{ | ||
$path=__DIR__.'/../fixtures/'; | ||
return [ | ||
['plaintext', ''], | ||
[123.2123, ''], | ||
[file_get_contents($path.'01.html'), $this->loadFormat($path.'01.css')], | ||
[file_get_contents($path.'02.html'), $this->loadFormat($path.'02.css')], | ||
[file_get_contents($path.'03.html'), $this->loadFormat($path.'03.css')], | ||
[file_get_contents($path.'04.html'), $this->loadFormat($path.'04.css')], | ||
]; | ||
} | ||
|
||
public function loadFormat($file) | ||
{ | ||
$format=file_get_contents($file); | ||
if (!$format) | ||
{ | ||
return false; | ||
} | ||
return str_replace('%w%w','%w','%w'.preg_replace('/\s/', '%w', $format).'%w'); | ||
} | ||
} | ||
<?php | ||
|
||
namespace SpazzMarticus\eCSStractor; | ||
|
||
/** | ||
* @uses \SpazzMarticus\eCSStractor\eCSStractor | ||
*/ | ||
class eCSStractorTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
protected $_eCSStractor; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->_eCSStractor=new eCSStractor(); | ||
} | ||
|
||
public function testLibxmlOptions() | ||
{ | ||
$this->_eCSStractor->setLibxmlOptions(1025); | ||
$this->assertSame(1025, $this->_eCSStractor->getLibxmlOptions()); | ||
} | ||
|
||
/** | ||
* @dataProvider providerExtract | ||
* @covers \SpazzMarticus\eCSStractor\eCSStractor::extract | ||
*/ | ||
public function testExtract($html, $cssFormat) | ||
{ | ||
$this->assertStringMatchesFormat($cssFormat, $this->_eCSStractor->extract($html)); | ||
} | ||
|
||
public function providerExtract() | ||
{ | ||
$path=__DIR__.'/../fixtures/'; | ||
return [ | ||
['plaintext', ''], | ||
[123.2123, ''], | ||
[file_get_contents($path.'01.html'), $this->loadFormat($path.'01.css')], | ||
[file_get_contents($path.'02.html'), $this->loadFormat($path.'02.css')], | ||
[file_get_contents($path.'03.html'), $this->loadFormat($path.'03.css')], | ||
[file_get_contents($path.'04.html'), $this->loadFormat($path.'04.css')], | ||
]; | ||
} | ||
|
||
public function loadFormat($file) | ||
{ | ||
$format=file_get_contents($file); | ||
if (!$format) | ||
{ | ||
return false; | ||
} | ||
/** | ||
* @see https://phpunit.readthedocs.io/en/8.1/assertions.html#assertstringmatchesformat | ||
* Replacing % by %% to work properly (e.g. width: 100%) , replacing whitespace by %w | ||
*/ | ||
return '%w'.preg_replace('/\s+/', '%w', preg_replace('/%/', '%%', $format)).'%w'; | ||
} | ||
} |