PHP Classes

File: testing/tests/TestAlignPHPCode2.php

Recommend this page to a friend!
  Classes of Subin Siby   PHPF   testing/tests/TestAlignPHPCode2.php   Download  
File: testing/tests/TestAlignPHPCode2.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: 7 years ago
Size: 1,020 bytes
 

Contents

Class file image Download
<?php

class TestAlignPHPCode2 extends PHPUnit_Framework_TestCase {

   
/**
     * @var string Code to test
     */
   
private $code = <<<CODE
<?php
require 'foo.php';
?>
<div>
    <?php
echo 'foo';
if ('foo' === 'bar'){

}
\$foo = <<<HTML
<div>
    <span></span>
</div>
HTML;
    ?>
</div>
CODE;

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

       
$expected_result = <<<CODE
<?php
require 'foo.php';
?>
<div>
    <?php
    echo 'foo';
    if ('foo' === 'bar') {

    }
    \$foo = <<<HTML
<div>
    <span></span>
</div>
HTML;
    ?>
</div>
CODE;

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

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

       
$expected_result = <<<CODE
<?php
require 'foo.php';
?>
<div>
    <?php
echo 'foo';
if ('foo' === 'bar') {

}
\$foo = <<<HTML
<div>
    <span></span>
</div>
HTML;
?>
</div>
CODE;

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

}