Skip to content

Commit

Permalink
Pug-php 3 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
kylekatarnls committed Oct 3, 2017
1 parent be451fa commit b0f4ff2
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 31 deletions.
60 changes: 37 additions & 23 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,50 @@
language: php

dist: trusty

sudo: required

php:
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2
- hhvm

matrix:
include:
- php: 5.3
dist: precise

include:
- php: 5.3
env: PUG_VERSION='2.7.1'
dist: precise
sudo: required
- php: 5.4
env: PUG_VERSION='2.7.1'
- php: 5.5
env: PUG_VERSION='2.7.1'
- php: 5.5
env: PUG_VERSION='^3.0@alpha'
- php: 5.6
env: PUG_VERSION='2.7.1'
- php: 5.6
env: PUG_VERSION='^3.0@alpha'
- php: 7.0
env: PUG_VERSION='2.7.1'
- php: 7.0
env: PUG_VERSION='^3.0@alpha'
- php: 7.1
env: PUG_VERSION='2.7.1'
- php: 7.1
env: PUG_VERSION='^3.0@alpha'
- php: 7.2
env: PUG_VERSION='2.7.1'
- php: 7.2
env: PUG_VERSION='^3.0@alpha'
- php: hhvm
env: PUG_VERSION='2.7.1'
dist: trusty
sudo: required
- php: hhvm
env: PUG_VERSION='^3.0@alpha'
dist: trusty
sudo: required
before_script:
- travis_retry composer self-update
- travis_retry composer install --no-interaction --prefer-source --dev

- if [ "$PUG_VERSION" != "" ]; then travis_retry composer require "pug-php/pug:${PUG_VERSION}" --no-update; fi;
- travis_retry composer update --no-interaction
script:
- vendor/bin/phpunit --verbose --coverage-text --coverage-clover=coverage.xml

after_script:
- vendor/bin/test-reporter --coverage-report coverage.xml

after_success:
- bash <(curl -s https://codecov.io/bash)

addons:
code_climate:
repo_token: 0a31b541cee9f52242db2fc659c6e7a91987bc80d860736d87ae88962fc10eaf
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
],
"minimum-stability": "stable",
"require": {
"pug-php/pug": "^2.0.2",
"pug-php/pug": "^2.0 || ^3.0",
"nodejs-php-fallback/react": "^1.3.0"
},
"require-dev": {
Expand Down
15 changes: 8 additions & 7 deletions tests/examples.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,23 @@ public function caseProvider()
/**
* @dataProvider caseProvider
*/
public function testJadeGeneration($htmlFile, $jadeFile)
public function testPugGeneration($htmlFile, $pugFile)
{
$jade = new Pug();
$renderedHtml = $jade->render($jadeFile, array(
'color' => 'yellow',
));
$pug = new Pug();
$renderFile = method_exists($pug, 'renderFile')
? array($pug, 'renderFile')
: array($pug, 'render');
$renderedHtml = call_user_func($renderFile, $pugFile);
$htmlFileContents = file_get_contents($htmlFile);

$actual = trim(preg_replace('`[\s_]+`', '', $renderedHtml));
$expected = trim(preg_replace('`[\s_]+`', '', $htmlFileContents));

$this->assertSame($expected, $actual, $jadeFile . ' should match ' . $htmlFile . ' as html');
$this->assertSame($expected, $actual, $pugFile . ' should match ' . $htmlFile . ' as html');

$actual = trim(preg_replace('`[\s_]+`', ' ', strip_tags($renderedHtml)));
$expected = trim(preg_replace('`[\s_]+`', ' ', strip_tags($htmlFileContents)));

$this->assertSame($expected, $actual, $jadeFile . ' should match ' . $htmlFile . ' as text');
$this->assertSame($expected, $actual, $pugFile . ' should match ' . $htmlFile . ' as text');
}
}

0 comments on commit b0f4ff2

Please sign in to comment.