D
D
Denis Ogurtsov2014-05-23 17:55:26
PHP
Denis Ogurtsov, 2014-05-23 17:55:26

How to test sequential method invocation within a method in PHPUNIT?

There is a code:

public function parseAction(){
    if ($this->beginParse()) {
        $this->parser();
    }
    $this->endParse();

How to test sequential method calls?
How I test: I write a mock for the class under test:
$handler =  $this->getMock('Handler', array('beginParse', 'parser','endParse'));

        $handler->expects($this->once())
            ->method('beginParse')
            ->will($this->returnValue(true));

       $handler->expects($this->once())
            ->method('parser')
            ->will($this->returnValue(true));

       $handler->expects($this->once())
            ->method('endParse')
            ->will($this->returnValue(true));

     $handler->parseAction();

But it gives an error that there is no parseAction method: the method is public
Call to undefined method Mock_Handler_8346bbfe::parseAction() in

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2014-05-23
Protko @Fesor

so where does it come from, you also need to lock it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question