Sunday, April 29, 2012

A question about test Mock

I met this error , Email still send . How i can  do protected function __sendVerifyEmail in UsersController return true , but don't send email ? (Funciton __sendVerifyEmail  use CakeEmail , not EmailComponent.)

Expectation failed for method name is equal to <string:__sendVerifyEmail> when invoked 1 time(s).  Method was expected to be called 1 times, actually called 0 times.

This is code lines :

 $this->Users = $this->generate('Users', array(
'components' => array(
'Session' => array('read')
)
));


$this->Users->expects($this->once())->method('__sendVerifyEmail')->will($this->returnValue(true));

$result = $this->testAction('/users/add', array(
    'data' => $data,
    'method' => 'post'
    ));

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: