PHP code example of phpdevcommunity / unitester

1. Go to this page and download the library: Download phpdevcommunity/unitester 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/ */

    

phpdevcommunity / unitester example snippets


class AssertionTest extends TestCase
{
    protected function setUp(): void
    {
        // Initialize any necessary resources before each test
    }

    protected function tearDown(): void
    {
        // Release resources after each test
    }

    protected function execute(): void
    {
        $this->testAssertTrue();
        $this->testAssertEquals();
    }

    public function testAssertTrue()
    {
        $this->assertTrue(true);
    }

    public function testAssertEquals()
    {
        $this->assertEquals(10, 5 + 5);
    }
}

your-project/
│
├── src/          # Directory containing your source code
├── tests/        # Directory containing your test classes
│   ├── AssertionTest.php
│   └── AnotherTest.php
└── ...
bash
php vendor/bin/unitester tests/