/** * @dataProvider getRequiredPaths * * @param bool $storage * @param bool $required * @param string $path */ public function testIsPathValid($storage, $required, $path) { if ($storage) { $storage = $this->getMock('\\AnimeDb\\Bundle\\CatalogBundle\\Entity\\Storage'); $storage->expects($this->once())->method('isPathRequired')->will($this->returnValue($required)); $this->item->setStorage($storage); } /* @var $context \PHPUnit_Framework_MockObject_MockObject|ExecutionContextInterface */ $context = $this->getMock('\\Symfony\\Component\\Validator\\ExecutionContextInterface'); $context->expects($storage && $required && !$path ? $this->once() : $this->never())->method('addViolationAt')->with('path', 'Path is required to fill for current type of storage'); $this->item->setPath($path); $this->item->isPathValid($context); }