Highly opinionated mocking framework for PHP 5.3+
           
               
           
            
        
            
             
              
      
                 
                
                
            
            
I'm currently trying to build mocks for an interface (defined here as the Policy class) which only has one method, check; as seen below I'm basically just replacing it with a stub method which always returns a known value:
$mockBuilder = $this->getMockBuilder(Policy::class);
$allowMock = $mockBuilder->getMock();
$allowMock->method('check')->willReturn(Vote::ALLOW);
It registers as an object implementing Policy, as it should, but whenever the check method is called it only ever returns null. What am I doing wrong in my construction here?
        Source: (StackOverflow)
                  
                 
            
                 
                
                
            
            
I've been moving my PHPUnit tests to use PHPSpec's Prophecy library - but I'm getting an odd error when using dummies of PHP DOMDocument:
class MyTest extends PHPUnit_Framework_TestCase {
    function testExample() {
        $inputDocument  = $this->prophesize("DOMDocument")->reveal();
        $outputDocument = $this->prophesize("DOMDocument")->reveal();
        $xsltProcessor = $this->prophesize("XSLTProcessor");
        $xsltProcessor->transformToDoc($inputDocument)->willReturn($outputDocument)->shouldBeCalled();
        $xsltProcessor = $xsltProcessor->reveal();
        $xsltProcessor->transformToDoc($inputDocument);
    }
}
I get an error ErrorException: DOMDocument::loadXML(): Empty string supplied as input
I'm not sure why loadXML is being called - these are supposed to be dummies...
        Source: (StackOverflow)