PHP code example of ddouggs / test_command

1. Go to this page and download the library: Download ddouggs/test_command library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ddouggs / test_command example snippets


namespace test_command;

public function __construct()
{
    $this->setArchives(new Archives());
}

TC::halt($output = [], $condition = true);
TC::begin($output = [], $condition = true);
TC::rollback($output = [], $condition = true);

TC::testing($configs = null, $test = null);

TC::assertBool(fn() => true);
TC::assertString(fn() => "texto");
TC::assertInt(fn() => 10);
TC::assertFloat(fn() => 10.5);
TC::assertArray(fn() => []);
TC::assertObject(fn() => new stdClass());
TC::assertResource(fn() => fopen(...));

TC::assertTrue(fn() => true);
TC::assertFalse(fn() => false);
TC::assertNull(fn() => null);
TC::assertEmpty(fn() => []);
TC::assertEquals($expected, fn() => $value);
TC::assertDiff($unexpected, fn() => $value);

TC::assertRegExp('/regex/', fn() => "valor");
TC::assertFileExists(fn() => "/caminho/arquivo");

TC::assertGreaterThan(10, fn() => 20);
TC::assertGreaterThanOrEqual(10, fn() => 10);
TC::assertLessThan(10, fn() => 5);
TC::assertLessThanOrEqual(10, fn() => 10);

TC::assertInstanceOf(MinhaClasse::class, fn() => new MinhaClasse());

use test_command\TC;

// Teste simples
TC::assertTrue(fn() => 1 === 1, 'Teste básico');

// Comparação
TC::assertEquals(10, fn() => 5 + 5);

// Breakpoint
TC::halt(['Erro encontrado'], true);