Skip to content

8.0 Codeception PHPUnit Tests

Gurdeep Singh (Guru) edited this page Aug 12, 2024 · 1 revision

Codeception

Download codeception from: https://codeception.com/install

Running tests

# Example RUN

guru@guru-lappy:/var/www/html/projects/phpfw$ codecept run unit
Codeception PHP Testing Framework v4.2.2 https://helpukrainewin.org
Powered by PHPUnit 8.5.28 #StandWithUkraine
[Seed] 1150854802

Unit Tests (16)------------------------------------------------------------------------------------------------------------------------------------------------------------------------
✔ FirewallTest: Get firewall config (0.01s)
✔ FirewallTest: Set config status (0.01s)
✔ FirewallTest: Set config filter (0.00s)
✔ FirewallTest: Set config range (0.00s)
✔ FirewallTest: Set config default filter (0.00s)
✔ FirewallTest: Set config auto unblock ip minutes (0.00s)
✔ FirewallTest: Set auto indexing (0.00s)
✔ FirewallTest: Set config ip2location io key (0.00s)
✔ FirewallTest: Set config ip2location key (0.00s)
✔ FirewallTest: Set ip2location primary lookup method (0.00s)
✔ FirewallTest: Set ip2location bin file code (0.00s)
✔ FirewallTest: Set ip2location proxy bin file code (0.00s)
✔ FirewallTest: Set ip2location bin access mode (0.00s)
✔ FirewallTest: Set ip2location proxy bin access mode (0.00s)
✔ FirewallTest: Add filters (0.01s)
✔ FirewallTest: Test filters (1.30s)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Time: 1.41 seconds, Memory: 20.66 MB

OK (16 tests, 80 assertions)

Adding ip2location keys

For Tests to work correctly, you need to add api keys to file Phpfirewall.php located under tests/_support/Helper/Phpfirewall.php

<?php
namespace Helper;

class Phpfirewall extends \Codeception\Module
{
    public function getKeys()
    {
        return
        [
            "key"       => "",
            "io_key"    => ""
        ];
    }
}