Skip to content

Commit

Permalink
Merge pull request #4724 from antograssiot/3.0-update-test
Browse files Browse the repository at this point in the history
3.0 minor test updates
  • Loading branch information
lorenzo committed Sep 25, 2014
2 parents 209bf7a + b0c43ce commit 0bde6a4
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 20 deletions.
5 changes: 2 additions & 3 deletions tests/TestCase/Shell/Task/TemplateTaskTest.php
Expand Up @@ -121,15 +121,14 @@ public function testGenerateWithTemplateFallbacks() {
$this->Task->initialize();
$this->Task->params['template'] = 'test';
$this->Task->set(array(
'name' => 'Article',
'model' => 'Article',
'name' => 'Articles',
'table' => 'articles',
'import' => false,
'records' => false,
'schema' => '',
'namespace' => ''
));
$result = $this->Task->generate('classes', 'fixture');
$this->assertRegExp('/ArticleFixture extends .*TestFixture/', $result);
$this->assertRegExp('/ArticlesFixture extends .*TestFixture/', $result);
}
}
53 changes: 37 additions & 16 deletions tests/TestCase/TestSuite/TestFixtureTest.php
Expand Up @@ -16,16 +16,17 @@

use Cake\Core\Configure;
use Cake\Datasource\ConnectionManager;
use Cake\Log\Log;
use Cake\Model\Model;
use Cake\TestSuite\Fixture\TestFixture;
use Cake\TestSuite\TestCase;
use Cake\Utility\ClassRegistry;

/**
* ArticleFixture class
* ArticlesFixture class
*
*/
class ArticleFixture extends TestFixture {
class ArticlesFixture extends TestFixture {

/**
* Table property
Expand Down Expand Up @@ -61,10 +62,10 @@ class ArticleFixture extends TestFixture {
}

/**
* StringFieldsTestFixture class
* StringsTestsFixture class
*
*/
class StringsTestFixture extends TestFixture {
class StringsTestsFixture extends TestFixture {

/**
* Table property
Expand Down Expand Up @@ -99,10 +100,10 @@ class StringsTestFixture extends TestFixture {


/**
* ImportFixture class
* ImportsFixture class
*
*/
class ImportFixture extends TestFixture {
class ImportsFixture extends TestFixture {

/**
* Import property
Expand Down Expand Up @@ -134,16 +135,36 @@ class TestFixtureTest extends TestCase {
*/
public $fixtures = ['core.posts'];

/**
* Set up
*
* @return void
*/
public function setUp() {
parent::setUp();
Log::reset();
}

/**
* Tear down
*
* @return void
*/
public function tearDown() {
parent::tearDown();
Log::reset();
}

/**
* test initializing a static fixture
*
* @return void
*/
public function testInitStaticFixture() {
$Fixture = new ArticleFixture();
$Fixture = new ArticlesFixture();
$this->assertEquals('articles', $Fixture->table);

$Fixture = new ArticleFixture();
$Fixture = new ArticlesFixture();
$Fixture->table = null;
$Fixture->init();
$this->assertEquals('articles', $Fixture->table);
Expand All @@ -168,7 +189,7 @@ public function testInitStaticFixture() {
* @return void
*/
public function testInitImport() {
$fixture = new ImportFixture();
$fixture = new ImportsFixture();
$fixture->fields = $fixture->records = null;
$fixture->import = [
'table' => 'posts',
Expand All @@ -192,7 +213,7 @@ public function testInitImport() {
* @return void
*/
public function testCreate() {
$fixture = new ArticleFixture();
$fixture = new ArticlesFixture();
$db = $this->getMock('Cake\Database\Connection', [], [], '', false);
$table = $this->getMock('Cake\Database\Schema\Table', [], ['articles']);
$table->expects($this->once())
Expand All @@ -215,7 +236,7 @@ public function testCreate() {
* @return void
*/
public function testCreateError() {
$fixture = new ArticleFixture();
$fixture = new ArticlesFixture();
$db = $this->getMock('Cake\Database\Connection', [], [], '', false);
$table = $this->getMock('Cake\Database\Schema\Table', [], ['articles']);
$table->expects($this->once())
Expand All @@ -233,7 +254,7 @@ public function testCreateError() {
* @return void
*/
public function testInsert() {
$fixture = new ArticleFixture();
$fixture = new ArticlesFixture();

$db = $this->getMock('Cake\Database\Connection', [], [], '', false);
$query = $this->getMock('Cake\Database\Query', [], [$db]);
Expand Down Expand Up @@ -284,7 +305,7 @@ public function testInsert() {
* @return void
*/
public function testInsertImport() {
$fixture = new ImportFixture();
$fixture = new ImportsFixture();

$db = $this->getMock('Cake\Database\Connection', [], [], '', false);
$query = $this->getMock('Cake\Database\Query', [], [$db]);
Expand Down Expand Up @@ -325,7 +346,7 @@ public function testInsertImport() {
* @return void
*/
public function testInsertStrings() {
$fixture = new StringsTestFixture();
$fixture = new StringsTestsFixture();

$db = $this->getMock('Cake\Database\Connection', [], [], '', false);
$query = $this->getMock('Cake\Database\Query', [], [$db]);
Expand Down Expand Up @@ -376,7 +397,7 @@ public function testInsertStrings() {
* @return void
*/
public function testDrop() {
$fixture = new ArticleFixture();
$fixture = new ArticlesFixture();

$db = $this->getMock('Cake\Database\Connection', [], [], '', false);
$statement = $this->getMock('\PDOStatement', ['closeCursor']);
Expand All @@ -401,7 +422,7 @@ public function testDrop() {
* @return void
*/
public function testTruncate() {
$fixture = new ArticleFixture();
$fixture = new ArticlesFixture();

$db = $this->getMock('Cake\Database\Connection', [], [], '', false);
$statement = $this->getMock('\PDOStatement', ['closeCursor']);
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Utility/StringTest.php
Expand Up @@ -1425,7 +1425,7 @@ public function testparseFileSize($params, $expected) {
}

/**
* testFromReadableSize
* testparseFileSizeException
*
* @expectedException InvalidArgumentException
* @return void
Expand Down

0 comments on commit 0bde6a4

Please sign in to comment.