-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 3.x: Updated the readme Fixed unit test and helper callback Added missing `use` statement. Bug fix. Required CakePHP. Updated Travis setup. Configured autoload for Composer. New Cake 3.x tests. Updated the helper. Remove Cake 2.x tests. Updated .editorconfig for Cake 3.x. # Conflicts: # Test/Case/View/Helper/InlineCssHelperTest.php # View/Helper/InlineCssHelper.php
- Loading branch information
Showing
12 changed files
with
228 additions
and
136 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
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,42 +1,50 @@ | ||
language: php | ||
|
||
php: | ||
- 5.3 | ||
- 5.4 | ||
- 5.5 | ||
- 5.6 | ||
|
||
env: | ||
global: | ||
- PLUGIN_NAME=InlineCss | ||
- REQUIRE="" | ||
- DB=mysql CAKE_VERSION=2.4 | ||
|
||
matrix: | ||
- DB=mysql CAKE_VERSION=2.4 | ||
- DB=mysql CAKE_VERSION=2.5 | ||
- DB=mysql CAKE_VERSION=2.6 | ||
- DB=mysql db_class='Cake\Database\Driver\Mysql' db_dsn='mysql:host=0.0.0.0;dbname=cakephp_test' db_database='cakephp_test' db_username='travis' db_password='' | ||
global: | ||
- DEFAULT=1 | ||
|
||
matrix: | ||
fast_finish: true | ||
|
||
include: | ||
- php: 5.4 | ||
env: | ||
- PHPCS=1 | ||
env: PHPCS=1 DEFAULT=0 | ||
|
||
- php: 5.5 | ||
env: COVERALLS=1 DEFAULT=0 | ||
|
||
allow_failures: | ||
- php: 5.4 | ||
env: | ||
- PHPCS=1 | ||
env: PHPCS=1 DEFAULT=0 | ||
|
||
before_script: | ||
- git clone https://github.com/FriendsOfCake/travis.git --depth 1 ../travis | ||
- ../travis/before_script.sh | ||
- echo "require APP . 'vendor' . DS . 'autoload.php';" >> ../cakephp/app/Config/bootstrap.php | ||
- composer self-update | ||
- composer install --prefer-source --no-interaction --dev | ||
|
||
script: | ||
- ../travis/script.sh | ||
- sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'CREATE DATABASE cakephp_test;'; fi" | ||
|
||
- sh -c "if [ '$PHPCS' = '1' ]; then composer require --dev cakephp/cakephp-codesniffer=2.*; fi" | ||
|
||
- sh -c "if [ '$COVERALLS' = '1' ]; then composer require --dev satooshi/php-coveralls:dev-master; fi" | ||
- sh -c "if [ '$COVERALLS' = '1' ]; then mkdir -p build/logs; fi" | ||
|
||
after_success: | ||
- ../travis/after_success.sh | ||
- phpenv rehash | ||
- set +H | ||
- cp phpunit.xml.dist phpunit.xml | ||
|
||
script: | ||
- sh -c "if [ '$COVERALLS' = '1' ]; then phpunit --coverage-clover build/logs/clover.xml; fi" | ||
- sh -c "if [ '$COVERALLS' = '1' ]; then php vendor/bin/coveralls -c .coveralls.yml -v; fi" | ||
- sh -c "if [ '$DEFAULT' = '1' ]; then phpunit; fi" | ||
- sh -c "if [ '$PHPCS' = '1' ]; then vendor/bin/phpcs -p --extensions=php --standard=vendor/cakephp/cakephp-codesniffer/CakePHP --ignore=tests src/ ; fi" | ||
|
||
notifications: | ||
email: false |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit | ||
colors="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
syntaxCheck="false" | ||
bootstrap="./tests/bootstrap.php" | ||
> | ||
<php> | ||
<ini name="memory_limit" value="-1"/> | ||
<ini name="apc.enable_cli" value="1"/> | ||
</php> | ||
|
||
<!-- Add any additional test suites you want to run here --> | ||
<testsuites> | ||
<testsuite name="App Test Suite"> | ||
<directory>./tests/TestCase</directory> | ||
</testsuite> | ||
<!-- Add plugin test suites here. --> | ||
</testsuites> | ||
|
||
<!-- Setup a listener for fixtures --> | ||
<listeners> | ||
<listener | ||
class="\Cake\TestSuite\Fixture\FixtureInjector" | ||
file="./vendor/cakephp/cakephp/src/TestSuite/Fixture/FixtureInjector.php"> | ||
<arguments> | ||
<object class="\Cake\TestSuite\Fixture\FixtureManager" /> | ||
</arguments> | ||
</listener> | ||
</listeners> | ||
|
||
<filter> | ||
<blacklist> | ||
<directory suffix=".php">./vendor/</directory> | ||
<directory suffix=".ctp">./vendor/</directory> | ||
|
||
<directory suffix=".php">./tests/</directory> | ||
<directory suffix=".ctp">./tests/</directory> | ||
</blacklist> | ||
</filter> | ||
|
||
</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
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
namespace InlineCss\View\Helper; | ||
|
||
use Cake\View\Helper; | ||
use TijsVerkoyen\CssToInlineStyles\CssToInlineStyles; | ||
|
||
class InlineCssHelper extends Helper | ||
{ | ||
|
||
/** | ||
* After layout logic. | ||
* | ||
* @param \Cake\Event\Event $event Event | ||
* @param string $layoutFile Layout filename | ||
*/ | ||
public function afterLayout(\Cake\Event\Event $event, $layoutFile) | ||
{ | ||
$content = $this->_View->Blocks->get('content'); | ||
|
||
if (!isset($this->InlineCss)) { | ||
$this->InlineCss = new CssToInlineStyles(); | ||
} | ||
|
||
// Convert inline style blocks to inline CSS on the HTML content. | ||
$this->InlineCss->setHTML($content); | ||
$this->InlineCss->setUseInlineStylesBlock(true); | ||
$content = $this->InlineCss->convert(); | ||
|
||
$this->_View->Blocks->set('content', $content); | ||
|
||
return; | ||
} | ||
|
||
} |
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
namespace InlineCss\TestCase\View\Helper; | ||
|
||
use Cake\Network\Request; | ||
use Cake\TestSuite\TestCase; | ||
use Cake\View\View; | ||
use InlineCss\View\Helper\InlineCssHelper; | ||
|
||
class InlineCssHelperTest extends TestCase | ||
{ | ||
|
||
public $InlineCss = null; | ||
|
||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$this->View = new View(new Request()); | ||
$this->InlineCss = new InlineCssHelper($this->View); | ||
} | ||
|
||
public function testAfterLayout() | ||
{ | ||
$this->View->Blocks->set('content', '<style type="text/css">a{color:red}</style><p><a href="#">Test</a></p>'); | ||
|
||
$this->InlineCss->afterLayout(new \Cake\Event\Event(''), null); | ||
|
||
$expected = '<p><a href="#" style="color: red;">Test</a></p>'; | ||
$this->assertContains($expected, $this->View->Blocks->get('content')); | ||
} | ||
|
||
} |
Oops, something went wrong.