Skip to content

Commit

Permalink
Simplifying assertions in FixtureTask test
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Sep 29, 2011
1 parent 6196e74 commit 27ab12d
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/Cake/Test/Case/Console/Command/Task/FixtureTaskTest.php
Expand Up @@ -208,7 +208,7 @@ public function testExecuteWithNamedModel() {
$filename = '/my/path/ArticleFixture.php';

$this->Task->expects($this->at(0))->method('createFile')
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class ArticleFixture/'));
->with($filename, $this->stringContains('class ArticleFixture'));

$this->Task->execute();
}
Expand All @@ -224,7 +224,7 @@ public function testExecuteIntoAll() {
$this->Task->args = array('all');
$this->Task->Model->expects($this->any())
->method('listAll')
->will($this->returnValue(array('Article', 'comments')));
->will($this->returnValue(array('articles', 'comments')));

$filename = '/my/path/ArticleFixture.php';
$this->Task->expects($this->at(0))
Expand All @@ -251,15 +251,15 @@ public function testAllWithCountAndRecordsFlags() {
$this->Task->params = array('count' => 10, 'records' => true);

$this->Task->Model->expects($this->any())->method('listAll')
->will($this->returnValue(array('articles', 'comments')));
->will($this->returnValue(array('Articles', 'comments')));

$filename = '/my/path/ArticleFixture.php';
$this->Task->expects($this->at(0))->method('createFile')
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/title\' => \'Third Article\'/'));
->with($filename, $this->stringContains("'title' => 'Third Article'"));

$filename = '/my/path/CommentFixture.php';
$this->Task->expects($this->at(1))->method('createFile')
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/comment\' => \'First Comment for First Article/'));
->with($filename, $this->stringContains("'comment' => 'First Comment for First Article'"));
$this->Task->expects($this->exactly(2))->method('createFile');

$this->Task->all();
Expand All @@ -282,7 +282,7 @@ public function testExecuteInteractive() {

$filename = '/my/path/ArticleFixture.php';
$this->Task->expects($this->once())->method('createFile')
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class ArticleFixture/'));
->with($filename, $this->stringContains('class ArticleFixture'));

$this->Task->execute();
}
Expand Down Expand Up @@ -349,10 +349,10 @@ public function testGenerateFixtureFile() {
$filename = '/my/path/ArticleFixture.php';

$this->Task->expects($this->at(0))->method('createFile')
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/ArticleFixture/'));
->with($filename, $this->stringContains('ArticleFixture'));

$this->Task->expects($this->at(1))->method('createFile')
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/\<\?php/ms'));
->with($filename, $this->stringContains('<?php'));

$result = $this->Task->generateFixtureFile('Article', array());

Expand All @@ -373,7 +373,7 @@ public function testGeneratePluginFixtureFile() {
//fake plugin path
CakePlugin::load('TestFixture', array('path' => APP . 'Plugin' . DS . 'TestFixture' . DS));
$this->Task->expects($this->at(0))->method('createFile')
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/Article/'));
->with($filename, $this->stringContains('class Article'));

$result = $this->Task->generateFixtureFile('Article', array());
CakePlugin::unload();
Expand Down

0 comments on commit 27ab12d

Please sign in to comment.