Skip to content

MarkM-Portfolio/kumu-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KUMU.API

API project base on YII2 basic

build

Quality Gate Status Bugs Code Smells Coverage Lines of Code

Unit Test


Run the below command under the project to get the unittest feedback.

./phpunit

Run the below command under the prooject to test the ChannelTest

./phpunit tests/Unit/ModelsTest/ChannelTest.php
./phpunit tests/Unit/ModelsTest/ChannelTest.php --no-coverage

How to write Test case with mock


  1. Mock redis
use \PHPUnit\Framework\TestCase;
use \Mockery;
use app\components\redis\HQRedis;

$HQRedisMock = Mockery::mock('alias:' . HQRedis::class);
  1. Mock DB
use \Mockery;
use yii\db\ActiveRecord;

$activeRecordMock = Mockery::mock('alias:' . ActiveRecord::class);
  1. Don't forget to close the mock
    public function tearDown(): void
    {
        Mockery::close();
        parent::tearDown();
    }

Code Coverage with visualize


  1. Install xdebug
  2. Uncomment phpunit.xml attribute log with coverage-html to output unittest html format.
    <log type="coverage-html" target="./tests/_report/coverage/" lowUpperBound="35" highLowerBound="70"/>
  3. Run command ./phpunit
  4. Open the file in tests/_report/coverage/index.html with your browser.
  5. Without coverage, run command ./phpunit --no-coverage

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors