PHP code example of ymmtmsys / command

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

    

ymmtmsys / command example snippets



use Ymmtmsys\Command\Command;

class Foo
{
    public function __construct($cmd) // $cmd is a Command instance
    {
        $this->cmd = $cmd;
    }

    public function bar()
    {
        // before process ...

        $this->cmd->exec($command);

        // after process  ...
    }
}

class FooTest extends \PHPUnit_Framework_TestCase
{
    public function testBar()
    {
        $mock_cmd = $this->getMock('Command', array('exec'));

        $obj = new Foo($mock_cmd);

        $obj->bar();

        // Assertions
    }
}