Testã§Fixturesã®ãã¼ã¿ãexpectedã«åå©ç¨ããã
Modelã®ãã¹ããããæã«ãModelããåå¾ã§ãããã¼ã¿ãã¨
ãFixturesã§å®ç¾©ãããã¼ã¿ããä¸è´ãã¦ããã確èªãããã¦fixtureãå¼ã³åºããªãã調ã¹ãã
$this->fixtureManager
ã£ã¦ããã¨CakeFixtureManagerãªãã¸ã§ã¯ããåããã®ã§ããã§ã´ãªã´ãªããã®ããªãã¨ãæã£ãã®ã ãã©ã
methodè¦ã¦ãããã£ã½ãã®ããªãã
ã§ãã°ã°ã£ãã
でぃべろっぱーってへてむる: CakePHPでテストする時にFixtureのデータを再利用してDRYにしよう
ãªãã»ã©ã¼ãªãã»ã©ã¼ã
åç´ã«App::importã§èªã¿è¾¼ãã§ãã®ãã¼ã
ã³ã¬ãåèã«ãä»è§¦ã£ã¦ãã®ã¯CakePHP2.0ãªã®ã§ãApp::importãã®ä»£ããã«ãApp::usesãã使ãããã«å¤æ´ãã
// åãã«App::usesã§å¼ã¶ App::uses('UserFixture', 'Test/Fixture'); // ãã¹ããããã¡ã½ããã§newãã $this->UserFixture = new UserFixture(); $expected = $this->UserFixture->records; $this->assertEquals($expected, $actual, 'Fixtureã®å¤ãè¿ã£ã¦ãã¦ããã');
ã¿ãããªæãã«ãã¾ããã