InlineCss = new InlineCssLib(['engine' => InlineCssLib::ENGINE_CSS_TO_INLINE]);
$result = App::import('Vendor', 'Tools.CssToInlineStyles', ['file' => 'CssToInlineStyles' . DS . 'CssToInlineStyles.php']);
$this->skipIf(!$result);
parent::setUp();
}
/**
* InlineCssLibTest::testProcess()
*
* @return void
*/
public function testProcess() {
$result = $this->InlineCss->process($this->testHtml);
$this->debug($this->testHtml);
$this->debug($result);
}
/**
* InlineCssLibTest::testProcessPlainPiece()
*
* @return void
*/
public function testProcessPlainPiece() {
$html = 'blabla
Sample Page Title
Bacon ipsum dolor sit amet in cow elit, in t-bone qui meatloaf corned beef aute ullamco minim. Consequat swine short ribs pastrami jerky.
Some small note!
bla';
$result = $this->InlineCss->process($html);
$this->debug($html);
$this->debug($result);
}
public $testHtml = '
Example
Sample Page Title
Bacon ipsum dolor sit amet in cow elit, in t-bone qui meatloaf corned beef aute ullamco minim. Consequat swine short ribs pastrami jerky.
Some small note!
';
/**
* InlineCssLibTest::testProcessUtf8()
*
* @return void
*/
public function testProcessUtf8() {
$this->skipIf(version_compare(PHP_VERSION, '5.4.0') < 0, 'UTF8 only works with PHP5.4 and above');
$html = 'チェック
チェック
降です。アーリーチェックインはリクエ
チェック\'foo\'
bla';
$result = $this->InlineCss->process($html);
$this->debug($html);
$this->debug($result);
$this->assertTextStartsWith('チェック', $result);
$this->assertTextContains('チェック
', $result);
}
/**
* InlineCssLibTest::testProcessSpecialChars()
*
* @return void
*/
public function testProcessSpecialChars() {
$this->skipIf(version_compare(PHP_VERSION, '5.4.0') < 0, 'UTF8 only works with PHP5.4 and above');
$html = '
bla';
$result = $this->InlineCss->process($html);
$expected = ' | ';
$this->debug($result);
$this->assertTextContains($expected, $result);
}
/**
* InlineCssLibTest::testProcessAlternativeEngine()
*
* @return void
*/
public function testProcessAlternativeEngine() {
$this->out('Emogrifier');
$this->InlineCss = new InlineCssLib(['engine' => InlineCssLib::ENGINE_EMOGRIFIER]);
$html = 'blabla
Sample Page Title
Bacon ipsum dolor sit amet in cow elit, in t-bone qui meatloaf corned beef aute ullamco minim. Consequat swine short ribs pastrami jerky.
Some small note!
bla';
$result = $this->InlineCss->process($html);
$this->debug($html);
$this->debug($result);
}
/**
* InlineCssLibTest::testProcessUtf8()
*
* @return void
*/
public function testProcessUtf8AlternativeEngine() {
$this->InlineCss = new InlineCssLib(['engine' => InlineCssLib::ENGINE_EMOGRIFIER]);
$html = 'チェック
チェック
降です。アーリーチェックインはリクエ
チェック\'foo\'
bla';
$result = $this->InlineCss->process($html);
$this->debug($html);
$this->debug($result);
//$this->assertTextStartsWith('チェック', $result);
//$this->assertTextContains('チェック
', $result);
}
/**
* InlineCssLibTest::testProcessSpecialChars()
*
* @return void
*/
public function testProcessSpecialCharsAlternativeEngine() {
$this->InlineCss = new InlineCssLib(['engine' => InlineCssLib::ENGINE_EMOGRIFIER]);
$html = '
bla';
$result = $this->InlineCss->process($html);
$this->debug($result);
}
/**
* InlineCssLibTest::testProcessSpecialChars()
*
* @return void
*/
public function testProcessCompleteTemplateAlternativeEngine() {
$path = CakePlugin::path('Tools') . 'Test' . DS . 'test_files' . DS . 'html' . DS;
$this->InlineCss = new InlineCssLib(['engine' => InlineCssLib::ENGINE_EMOGRIFIER]);
$html = file_get_contents($path . 'email_template.html');
$result = $this->InlineCss->process($html);
$this->debug($result);
$expected = 'assertTextContains($expected, $result);
$this->assertTextContains('香港酒店', $result);
}
}
|