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()
$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;
Here is the Error Message i’m getting:
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.