HOWTOlabs  
 Services     Software     Commentary     Design     Astral Musings   
PHPUnit
Setup and basic uses

Related

Elsewhere [ edit ]

PHPUnit is a set of tools to help developers quickly find mistakes in newly committed PHP code to help catch possible code regression. 

# yum install php phpunit

  [ CentOS / RHEL 7 setup ]  

And here is a rather simplistic test suite.

$ ls

  tests
    `-SmokeTest.php
  phpunit.xml

$ cat phpunit.xml 

  <phpunit>
  <!--  phpunit bootstrap="autoload.php"  -->
    <testsuites>
      <testsuite name="mytake">
        <directory>tests
      </testsuite>
    </testsuites>
  </phpunit>

$ cat tests/SmokeTest.php 

  <?php

  use PHPUnit\Framework\TestCase;

  class SmokeTest extends PHPUnit_Framework_TestCase {

      public function testSmoke() {
          // Assert
          $this->assertEquals(1, 1);
      }

  }  

$ phpunit

  PHPUnit 4.8.27 by Sebastian Bergmann and contributors.

  .

  Time: 52 ms, Memory: 4.00Mb

  OK (1 test, 1 assertion)  
zap technologies
tablet | printable