FireTest – API Documentation

UA1Labs\Fire\Test\Suite

__construct($dir, $fileExt = ‘.TestCase.php’)

The class constructor.

  • @param string $dir The directory you would like to run this test suite for
  • @param string $fileExt The file extension that will indicate FireTest cases
  • @return void
<?php
$testSuite = new \UA1Labs\Fire\Test\Suite(__DIR__ . '/.', '.TestCase.php');

run()

The run logic used to run the suite of test cases and tests.

  • @return void
<?php
$testSuite = new \UA1Labs\Fire\Test\Suite(__DIR__ . '/.', '.TestCase.php');
$testSuite->run();

[static] log($text)

This method is responsible for logging messages to the command line. It is a static method and will allow you to log without having to have an instance of the class.

  • @param string $text The text you would like to have logged.
  • @return void
<?php
// calling it statically
\UA1Labs\Fire\Test\Suite::log('Log message here');

// calling it from an instance object
$testSuite = new \UA1Labs\Fire\Test\Suite('/.', '.TestCase.php');
$testSuite->log('Log message here');

[abstract] UA1Labs\Fire\Test\TestCase

should($statement)

Method used to set the current test’s should statement. This method call should be paired with ::assert().

  • @param string $statement The statement you want to test against
  • @return UA1Labs\Fire\Test\TestCase
<?php
use \UA1Labs\Fire\Test\TestCase;

class MyTestCase extends TestCase 
{
    testMyFirstTest()
    {
        $this->should('Return true when called');
        $this->assert(true);
    }
} 

assert($true)

Method used to determine if a test passes or fails.

  • @param boolean $true The statement you want to test
  • @return UA1Labs\Fire\Test\TestCase
<?php
use \UA1Labs\Fire\Test\TestCase;

class MyTestCase extends TestCase 
{
    testMyFirstTest()
    {
        $this->should('Return true when called');
        $this->assert(true);
    }
} 

setUp()

A method that is invoked when the when the testcase is first intialized.

  • @return void
<?php
use \UA1Labs\Fire\Test\TestCase;

class MyTestCase extends TestCase 
{
    setUp()
    {
        // setup logic here
    }
} 

beforeEach()

A method that is invoked before each test method is invoked.

  • @return void
<?php
use \UA1Labs\Fire\Test\TestCase;

class MyTestCase extends TestCase 
{
    beforeEach()
    {
        // before each logic here
    }
}

afterEach()

A method that is invoked after each test method is invoked.

  • @return void
<?php
use \UA1Labs\Fire\Test\TestCase;

class MyTestCase extends TestCase 
{
    afterEach()
    {
        // after each logic here
    }
}

tearDown()

A method that is invoked when the test case is finish running all test methods.

  • @return void
<?php
use \UA1Labs\Fire\Test\TestCase;

class MyTestCase extends TestCase 
{
    tearDown()
    {
        // tear down logic here
    }
}

getMockObject($className, $methodOverrideValues = [])

Returns a mocked object of $className type you request. $methodOverrideValues keys will override methods by the same name and set their return value to the value you pass into the array.

  • @param string $className The class you want to mock
  • @param array $methodOverrideValues An associative array of override methods mapped to value they should return
  • @throws \UA1Labs\Fire\TestException If the class doesn’t exist
  • @throws \UA1Labs\Fire\TestException If an override method cannot be overridden
  • @return object
<?php
use \UA1Labs\Fire\Test\TestCase;

class MyTestCase extends TestCase 
{
    testMyFirstTest()
    {
        $mock = $this->getMockObject(MyClass::class);
    }
} 

Leave a comment

Leave a Reply