Try giving it the full namespace (use App\SomeNamespace\Calculator; at the top of the test file)
$calculator = $this->getMockBuilder(Calculator::class)
The following test passes WITHOUT the underlying SUT
public function testWithStub()
{
// Create a stub for the LoanCalculator class.
$calculator = $this->getMockBuilder('Calculator')
->setMethods(['add'])
->getMock();
// Configure the stub.
$calculator->expects($this->any())
->method('add')
->will($this->returnValue(6));
$this->assertEquals(6, $calculator->add(100,100));
}
The class being tested doesn't exist. Why is the test passing?
Try giving it the full namespace (use App\SomeNamespace\Calculator; at the top of the test file)
$calculator = $this->getMockBuilder(Calculator::class)
Please or to participate in this conversation.