PHP Classes

File: testing/tests/TestAlignPHPCode.php

Recommend this page to a friend!
  Classes of Subin Siby   PHPF   testing/tests/TestAlignPHPCode.php   Download  
File: testing/tests/TestAlignPHPCode.php
Role: Unit test script
Content type: text/plain
Description: Unit test script
Class: PHPF
Reformat PHP scripts according to code style
Author: By
Last change: Fix Heredoc string alignment

Both `AlignPHPCode` & `AlignPHPCode2` passes would add indentation
to first line in heredoc string. This bug has been fixed.
Date: 6 years ago
Size: 934 bytes
 

Contents

Class file image Download
<?php

class TestAlignPHPCode extends PHPUnit_Framework_TestCase {

   
/**
     * @var string Code to test
     */
   
private $code = <<<CODE
<?php
require 'foo.php';
?>
<div>
<?php
echo 'foo';
\$foo = <<<HTML
<div>
    <span></span>
</div>
HTML;
?>
</div>
CODE;

    public function
testEnabled() {
       
$output = executeCommand(
            array(
               
'--passes' => 'AlignPHPCode',
            ),
           
$this->code
       
);

       
$expected_result = <<<CODE
<?php
    require 'foo.php';
?>
<div>
<?php
    echo 'foo';
    \$foo = <<<HTML
<div>
    <span></span>
</div>
HTML;
?>
</div>
CODE;

       
$this->assertContains( $expected_result, $output );
    }

    public function
testDisabled() {
       
$output = executeCommand(
            array(
               
'--exclude' => 'AlignPHPCode',
            ),
           
$this->code
       
);

       
$expected_result = <<<CODE
<?php
require 'foo.php';
?>
<div>
<?php
echo 'foo';
\$foo = <<<HTML
<div>
    <span></span>
</div>
HTML;
?>
</div>
CODE;

       
$this->assertContains( $expected_result, $output );
    }

}