How to Unit Test a Shell Task?

Hello!

I wrote an Shell Task performing the creation of some XML Document.
Now I’d like to Unit Test this Task.
My Question is how. And my Problem is, that the MockBuilder is not really creating a Mock.

Here’s the Code of my setUp() Function.

public function setUp()
{
parent::setUp();
$this->io = $this->getMockBuilder(‘Cake\Console\ConsoleIo’)->getMock();

    $this->PrepareCatalog = $this->getMockBuilder('Mercateo\Shell\Task\PrepareCatalogTask')
        ->setConstructorArgs([$this->io])
        ->getMock();

}
The “PrepareCatalogTask” is (of Course) invoked by a Shell.

I’ve written a simple math Function in the PrepareCatalogTask:

public function mathAdd($a,$b)
{
$c = $a + $b;
return $c;
}
Here is the Error Message i’m getting:

  1. Mercateo\Test\TestCase\Shell\Task\PrepareCatalogTaskTest::testMathAdd
    Failed asserting that null matches expected 9.
    So, the PrepareCatalogTask Object has not been instantiated respectively the Mock Builder is not doing what I hope he’s doing.

Any suggestions?
Thx!!