Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Convert remaining uses of moved functions over to new class.
Change references to Table methods to use TableRegistry.
  • Loading branch information
markstory committed Oct 20, 2013
1 parent fc23f74 commit 38e7469
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 68 deletions.
24 changes: 13 additions & 11 deletions Cake/Test/TestCase/ORM/Association/BelongsToManyTest.php
Expand Up @@ -19,12 +19,14 @@
use Cake\ORM\Association\BelongsToMany;
use Cake\ORM\Query;
use Cake\ORM\Table;
use Cake\ORM\TableRegistry;
use Cake\TestSuite\TestCase;

/**
* Tests BelongsToMany class
*
*/
class BelongsToManyTest extends \Cake\TestSuite\TestCase {
class BelongsToManyTest extends TestCase {

/**
* Set up
Expand All @@ -47,7 +49,7 @@ public function setUp() {
'id' => ['type' => 'integer'],
'name' => ['type' => 'string'],
]);
Table::instance('Article', $this->article);
TableRegistry::set('Article', $this->article);
}

/**
Expand All @@ -57,7 +59,7 @@ public function setUp() {
*/
public function tearDown() {
parent::tearDown();
Table::clearRegistry();
TableRegistry::clear();
}

/**
Expand Down Expand Up @@ -126,7 +128,7 @@ public function testPivot() {
$this->assertInstanceOf($hasMany, $this->tag->association('ArticlesTag'));

$this->assertSame($pivot, $assoc->pivot());
$pivot2 = Table::build('Foo');
$pivot2 = TableRegistry::get('Foo');
$assoc->pivot($pivot2);
$this->assertSame($pivot2, $assoc->pivot());

Expand Down Expand Up @@ -163,7 +165,7 @@ public function testAttachTo() {
'targetTable' => $this->tag,
'conditions' => ['Tag.name' => 'cake']
];
Table::build('ArticlesTag', [
TableRegistry::get('ArticlesTag', [
'table' => 'articles_tags',
'schema' => [
'article_id' => ['type' => 'integer'],
Expand Down Expand Up @@ -213,7 +215,7 @@ public function testAttachToNoFields() {
'targetTable' => $this->tag,
'conditions' => ['Tag.name' => 'cake']
];
Table::build('ArticlesTag', [
TableRegistry::get('ArticlesTag', [
'table' => 'articles_tags',
'schema' => [
'article_id' => ['type' => 'integer'],
Expand Down Expand Up @@ -254,7 +256,7 @@ public function testEagerLoader() {
'sourceTable' => $this->article,
'targetTable' => $this->tag,
];
Table::build('ArticlesTag', [
TableRegistry::get('ArticlesTag', [
'table' => 'articles_tags',
'schema' => [
'article_id' => ['type' => 'integer'],
Expand Down Expand Up @@ -310,7 +312,7 @@ public function testEagerLoaderWithDefaults() {
'conditions' => ['Tag.name' => 'foo'],
'sort' => ['id' => 'ASC'],
];
Table::build('ArticlesTag', [
TableRegistry::get('ArticlesTag', [
'table' => 'articles_tags',
'schema' => [
'article_id' => ['type' => 'integer'],
Expand Down Expand Up @@ -362,7 +364,7 @@ public function testEagerLoaderWithOverrides() {
'conditions' => ['Tag.name' => 'foo'],
'sort' => ['id' => 'ASC'],
];
Table::build('ArticlesTag', [
TableRegistry::get('ArticlesTag', [
'table' => 'articles_tags',
'schema' => [
'article_id' => ['type' => 'integer'],
Expand Down Expand Up @@ -432,7 +434,7 @@ public function testEagerLoaderFieldsException() {
'conditions' => ['Tag.name' => 'foo'],
'sort' => ['id' => 'ASC'],
];
Table::build('ArticlesTag', [
TableRegistry::get('ArticlesTag', [
'table' => 'articles_tags',
'schema' => [
'article_id' => ['type' => 'integer'],
Expand Down Expand Up @@ -468,7 +470,7 @@ public function testEagerLoaderSubquery() {
'conditions' => ['Tag.name' => 'foo'],
'sort' => ['id' => 'ASC'],
];
Table::build('ArticlesTag', [
TableRegistry::get('ArticlesTag', [
'table' => 'articles_tags',
'schema' => [
'article_id' => ['type' => 'integer'],
Expand Down
7 changes: 4 additions & 3 deletions Cake/Test/TestCase/ORM/Association/BelongsToTest.php
Expand Up @@ -19,6 +19,7 @@
use Cake\ORM\Association\BelongsTo;
use Cake\ORM\Query;
use Cake\ORM\Table;
use Cake\ORM\TableRegistry;

/**
* Tests BelongsTo class
Expand All @@ -33,13 +34,13 @@ class BelongsToTest extends \Cake\TestSuite\TestCase {
*/
public function setUp() {
parent::setUp();
$this->company = Table::build('Company', [
$this->company = TableRegistry::get('Company', [
'schema' => [
'id' => ['type' => 'integer'],
'company_name' => ['type' => 'string'],
]
]);
$this->client = Table::build('Client', [
$this->client = TableRegistry::get('Client', [
'schema' => [
'id' => ['type' => 'integer'],
'client_name' => ['type' => 'string'],
Expand All @@ -55,7 +56,7 @@ public function setUp() {
*/
public function tearDown() {
parent::tearDown();
Table::clearRegistry();
TableRegistry::clear();
}

/**
Expand Down
5 changes: 3 additions & 2 deletions Cake/Test/TestCase/ORM/Association/HasManyTest.php
Expand Up @@ -19,6 +19,7 @@
use Cake\ORM\Association\HasMany;
use Cake\ORM\Query;
use Cake\ORM\Table;
use Cake\ORM\TableRegistry;

/**
* Tests HasMany class
Expand All @@ -33,7 +34,7 @@ class HasManyTest extends \Cake\TestSuite\TestCase {
*/
public function setUp() {
parent::setUp();
$this->author = Table::build('Author', [
$this->author = TableRegistry::get('Author', [
'schema' => [
'id' => ['type' => 'integer'],
'username' => ['type' => 'string'],
Expand All @@ -56,7 +57,7 @@ public function setUp() {
*/
public function tearDown() {
parent::tearDown();
Table::clearRegistry();
TableRegistry::clear();
}

/**
Expand Down
7 changes: 4 additions & 3 deletions Cake/Test/TestCase/ORM/Association/HasOneTest.php
Expand Up @@ -19,6 +19,7 @@
use Cake\ORM\Association\HasOne;
use Cake\ORM\Query;
use Cake\ORM\Table;
use Cake\ORM\TableRegistry;

/**
* Tests HasOne class
Expand All @@ -33,13 +34,13 @@ class HasOneTest extends \Cake\TestSuite\TestCase {
*/
public function setUp() {
parent::setUp();
$this->user = Table::build('User', [
$this->user = TableRegistry::get('User', [
'schema' => [
'id' => ['type' => 'integer'],
'username' => ['type' => 'string'],
]
]);
$this->profile = Table::build('Profile', [
$this->profile = TableRegistry::get('Profile', [
'schema' => [
'id' => ['type' => 'integer'],
'first_name' => ['type' => 'string'],
Expand All @@ -55,7 +56,7 @@ public function setUp() {
*/
public function tearDown() {
parent::tearDown();
Table::clearRegistry();
TableRegistry::clear();
}

/**
Expand Down
5 changes: 3 additions & 2 deletions Cake/Test/TestCase/ORM/AssociationTest.php
Expand Up @@ -18,11 +18,12 @@

use Cake\ORM\Association;
use Cake\ORM\Table;
use Cake\ORM\TableRegistry;

/**
* A Test double used to assert that default tables are created
*
**/
*/
class TestTable extends Table {

}
Expand Down Expand Up @@ -63,7 +64,7 @@ public function setUp() {
*/
public function tearDown() {
parent::tearDown();
Table::clearRegistry();
TableRegistry::clear();
}

/**
Expand Down

0 comments on commit 38e7469

Please sign in to comment.