LoginSignup
0
0

More than 5 years have passed since last update.

CakePHP2でモデルをモックするとBehaviorが外れるのでその対処

Last updated at Posted at 2016-09-16

よく忘れるので自分の備忘録として残します

// Mock生成
$mockModel = $this->getMockForModel('Hoge', ['save']);

// 保存に失敗するように振る舞いを定義
$mockModel->expects($this->once())->method('save')->will($this->returnValue(false));

// Behaviorsに必要なものをアタッチ(これ忘れる orz)
$mockModel->Behaviors->attach('Containable');

// テスト実行
・・・
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0