0

I need to test following constructor which has dependency injection using phpunit. For that do I have to use mocking ? If so please give an example.

/**
 * Set graph object
 *
 * @param Graph $graphObj graph object
 */
public function __construct(Graph $graphObj)
{
    $this->graphObject = $graphObj;
}

1 Answer 1

2

Assuming phpunit:

$mockGraph = $this->getMockBuilder('Graph')
                  ->setMethods(array('update'))
                  ->getMock();
$testObject = new Object($mockGraph);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.