Skip to content

Commit

Permalink
create tests for baking a test for a component, behavior and helper
Browse files Browse the repository at this point in the history
  • Loading branch information
AD7six committed Apr 29, 2012
1 parent 6b6fdd2 commit 6a744b2
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions lib/Cake/Test/Case/Console/Command/Task/TestTaskTest.php
Expand Up @@ -487,6 +487,69 @@ public function testBakeControllerTest() {
$this->assertContains("'app.articles_tag'", $result);
}

/**
* test baking component test files,
*
* @return void
*/
public function testBakeComponentTest() {
$this->Task->expects($this->once())->method('createFile')->will($this->returnValue(true));

$result = $this->Task->bake('Component', 'Example');

$this->assertContains("App::uses('ExampleComponent', 'Controller/Component')", $result);
$this->assertContains('class ExampleComponentTest extends CakeTestCase', $result);

$this->assertContains('function setUp()', $result);
$this->assertContains("\$Collection = new ComponentCollection()", $result);
$this->assertContains("\$this->Example = new ExampleComponent(\$Collection)", $result);

$this->assertContains('function tearDown()', $result);
$this->assertContains('unset($this->Example)', $result);
}

/**
* test baking behavior test files,
*
* @return void
*/
public function testBakeBehaviorTest() {
$this->Task->expects($this->once())->method('createFile')->will($this->returnValue(true));

$result = $this->Task->bake('Behavior', 'Example');

$this->assertContains("App::uses('ExampleBehavior', 'Model/Behavior')", $result);
$this->assertContains('class ExampleBehaviorTest extends CakeTestCase', $result);

$this->assertContains('function setUp()', $result);
$this->assertContains("\$this->Example = new ExampleBehavior()", $result);

$this->assertContains('function tearDown()', $result);
$this->assertContains('unset($this->Example)', $result);
}

/**
* test baking helper test files,
*
* @return void
*/
public function testBakeHelperTest() {
$this->Task->expects($this->once())->method('createFile')->will($this->returnValue(true));

$result = $this->Task->bake('Helper', 'Example');

$this->assertContains("App::uses('ExampleHelper', 'View/Helper')", $result);
$this->assertContains('class ExampleHelperTest extends CakeTestCase', $result);

$this->assertContains('function setUp()', $result);
$this->assertContains("\$View = new View()", $result);
$this->assertContains("\$this->Example = new ExampleHelper(\$View)", $result);

$this->assertContains('function tearDown()', $result);
$this->assertContains('unset($this->Example)', $result);
}


/**
* test Constructor generation ensure that constructClasses is called for controllers
*
Expand Down

0 comments on commit 6a744b2

Please sign in to comment.