diff --git a/.editorconfig b/.editorconfig index a4e9086..de2fe7e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -4,7 +4,7 @@ root = true [*] -indent_style = tab +indent_style = space indent_size = 4 charset = "utf-8" end_of_line = lf diff --git a/.travis.yml b/.travis.yml index 8f5d3ab..806581d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/Test/Case/AllInlineCssTest.php b/Test/Case/AllInlineCssTest.php deleted file mode 100644 index 5d4a9e7..0000000 --- a/Test/Case/AllInlineCssTest.php +++ /dev/null @@ -1,21 +0,0 @@ -addTestDirectoryRecursive($path); - - return $suite; - } -} \ No newline at end of file diff --git a/Test/Case/View/Helper/InlineCssHelperTest.php b/Test/Case/View/Helper/InlineCssHelperTest.php deleted file mode 100644 index 9710790..0000000 --- a/Test/Case/View/Helper/InlineCssHelperTest.php +++ /dev/null @@ -1,37 +0,0 @@ -View = new View($Controller); - $this->InlineCss = new InlineCssHelper($this->View); - } - - public function testAfterLayout() { - $html = $this->View->Blocks->set('content', '
'); - - $this->InlineCss->afterLayout(null); - - $expected = ''; - $this->assertContains($expected, $this->View->Blocks->get('content')); - } - - public function testIsHtml() { - $html = 'Hello World
'; - $result = $this->InlineCss->isHtml($html); - $this->assertTrue($result); - - $text = 'Hello World'; - $result = $this->InlineCss->isHtml($text); - $this->assertFalse($result); - } - -} diff --git a/View/Helper/InlineCssHelper.php b/View/Helper/InlineCssHelper.php deleted file mode 100644 index 95a39a8..0000000 --- a/View/Helper/InlineCssHelper.php +++ /dev/null @@ -1,48 +0,0 @@ -_View->Blocks->get('content'); - - // We only want to apply inline CSS to HTML emails, so first check if - // the content is HTML before proceeding. - if ($this->isHtml($content) === false) { - return; - } - - 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; - } - -/** - * Checks if a string contains HTML or not. - * - * @param string $str String content - * @return bool - */ - public function isHtml($str) { - return $str !== strip_tags($str); - } - -} diff --git a/composer.json b/composer.json index 69032a6..8039422 100644 --- a/composer.json +++ b/composer.json @@ -12,9 +12,18 @@ } ], "require": { + "cakephp/cakephp": "~3.0", "tijsverkoyen/css-to-inline-styles": "^1.5" }, - "extra": { - "installer-name": "InlineCss" + "autoload": { + "psr-4": { + "InlineCss\\": "src" + } + }, + "autoload-dev": { + "psr-4": { + "Cake\\Test\\": "./vendor/cakephp/cakephp/tests", + "InlineCss\\Test\\": "tests" + } } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..154dae2 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,43 @@ + +