mscherer 5 years ago
parent
commit
565e49b569

+ 1 - 2
tests/TestCase/Auth/MultiColumnAuthenticateTest.php

@@ -4,7 +4,6 @@ namespace Tools\Test\TestCase\Auth;
 
 use Cake\Http\ServerRequest;
 use Cake\I18n\Time;
-use Cake\ORM\TableRegistry;
 use Cake\TestSuite\TestCase;
 use Tools\Auth\MultiColumnAuthenticate;
 
@@ -46,7 +45,7 @@ class MultiColumnAuthenticateTest extends TestCase {
 		]);
 
 		$password = password_hash('password', PASSWORD_DEFAULT);
-		$MultiColumnUsers = TableRegistry::getTableLocator()->get('MultiColumnUsers');
+		$MultiColumnUsers = $this->getTableLocator()->get('MultiColumnUsers');
 		$MultiColumnUsers->updateAll(['password' => $password], []);
 
 		$this->response = $this->getMockBuilder('Cake\Http\Response')->getMock();

+ 1 - 2
tests/TestCase/Controller/ControllerTest.php

@@ -3,7 +3,6 @@
 namespace Tools\Test\TestCase\Controller;
 
 use Cake\Core\Configure;
-use Cake\ORM\TableRegistry;
 use Shim\TestSuite\TestCase;
 use Tools\Controller\Controller;
 
@@ -46,7 +45,7 @@ class ControllerTest extends TestCase {
 	public function testPaginate() {
 		Configure::write('Paginator.limit', 2);
 
-		$ToolsUser = TableRegistry::getTableLocator()->get('ToolsUsers');
+		$ToolsUser = $this->getTableLocator()->get('ToolsUsers');
 
 		$count = $ToolsUser->find()->count();
 		$this->assertTrue($count > 3);

+ 1 - 2
tests/TestCase/Model/Behavior/AfterSaveBehaviorTest.php

@@ -2,7 +2,6 @@
 
 namespace Tools\Test\TestCase\Model\Behavior;
 
-use Cake\ORM\TableRegistry;
 use Shim\TestSuite\TestCase;
 
 class AfterSaveBehaviorTest extends TestCase {
@@ -25,7 +24,7 @@ class AfterSaveBehaviorTest extends TestCase {
 	public function setUp(): void {
 		parent::setUp();
 
-		$this->table = TableRegistry::getTableLocator()->get('Articles');
+		$this->table = $this->getTableLocator()->get('Articles');
 		$this->table->addBehavior('Tools.AfterSave');
 	}
 

+ 1 - 2
tests/TestCase/Model/Behavior/BitmaskedBehaviorTest.php

@@ -2,7 +2,6 @@
 
 namespace Tools\Test\TestCase\Model\Behavior;
 
-use Cake\ORM\TableRegistry;
 use RuntimeException;
 use Shim\TestSuite\TestCase;
 use TestApp\Model\Entity\BitmaskedComment;
@@ -27,7 +26,7 @@ class BitmaskedBehaviorTest extends TestCase {
 	public function setUp(): void {
 		parent::setUp();
 
-		$this->Comments = TableRegistry::getTableLocator()->get('BitmaskedComments');
+		$this->Comments = $this->getTableLocator()->get('BitmaskedComments');
 		$this->Comments->addBehavior('Tools.Bitmasked', ['mappedField' => 'statuses']);
 	}
 

+ 3 - 4
tests/TestCase/Model/Behavior/ConfirmableBehaviorTest.php

@@ -2,7 +2,6 @@
 
 namespace Tools\Test\TestCase\Model\Behavior;
 
-use Cake\ORM\TableRegistry;
 use Shim\TestSuite\TestCase;
 
 class ConfirmableBehaviorTest extends TestCase {
@@ -32,7 +31,7 @@ class ConfirmableBehaviorTest extends TestCase {
 	 * @return void
 	 */
 	public function testBasicValidation() {
-		$this->Articles = TableRegistry::getTableLocator()->get('SluggedArticles');
+		$this->Articles = $this->getTableLocator()->get('SluggedArticles');
 		$this->Articles->addBehavior('Tools.Confirmable');
 
 		$animal = $this->Articles->newEmptyEntity();
@@ -57,7 +56,7 @@ class ConfirmableBehaviorTest extends TestCase {
 	 * @return void
 	 */
 	public function testValidationThatHasBeenModifiedBefore() {
-		$this->Articles = TableRegistry::getTableLocator()->get('SluggedArticles');
+		$this->Articles = $this->getTableLocator()->get('SluggedArticles');
 		/*
 		$this->Articles->validator()->add('confirm', 'notBlank', [
 				'rule' => function ($value, $context) {
@@ -96,7 +95,7 @@ class ConfirmableBehaviorTest extends TestCase {
 	 * @return void
 	 */
 	public function testValidationFieldMissing() {
-		$this->Articles = TableRegistry::getTableLocator()->get('SluggedArticles');
+		$this->Articles = $this->getTableLocator()->get('SluggedArticles');
 		$this->Articles->addBehavior('Tools.Confirmable');
 
 		$animal = $this->Articles->newEmptyEntity();

+ 1 - 2
tests/TestCase/Model/Behavior/JsonableBehaviorTest.php

@@ -2,7 +2,6 @@
 
 namespace Tools\Test\TestCase\Model\Behavior;
 
-use Cake\ORM\TableRegistry;
 use PDOException;
 use Shim\TestSuite\TestCase;
 use stdClass;
@@ -27,7 +26,7 @@ class JsonableBehaviorTest extends TestCase {
 	public function setUp(): void {
 		parent::setUp();
 
-		$this->Comments = TableRegistry::getTableLocator()->get('JsonableComments');
+		$this->Comments = $this->getTableLocator()->get('JsonableComments');
 		$this->Comments->addBehavior('Tools.Jsonable', ['fields' => ['details']]);
 	}
 

+ 2 - 3
tests/TestCase/Model/Behavior/NeighborBehaviorTest.php

@@ -2,7 +2,6 @@
 
 namespace Tools\Test\TestCase\Model\Behavior;
 
-use Cake\ORM\TableRegistry;
 use Shim\TestSuite\TestCase;
 
 class NeighborBehaviorTest extends TestCase {
@@ -25,7 +24,7 @@ class NeighborBehaviorTest extends TestCase {
 	public function setUp(): void {
 		parent::setUp();
 
-		$this->Table = TableRegistry::getTableLocator()->get('Stories');
+		$this->Table = $this->getTableLocator()->get('Stories');
 		$this->Table->addBehavior('Tools.Neighbor');
 	}
 
@@ -33,7 +32,7 @@ class NeighborBehaviorTest extends TestCase {
 	 * @return void
 	 */
 	public function tearDown(): void {
-		TableRegistry::clear();
+		$this->getTableLocator()->clear();
 
 		parent::tearDown();
 	}

+ 2 - 3
tests/TestCase/Model/Behavior/PasswordableBehaviorTest.php

@@ -4,7 +4,6 @@ namespace Tools\Test\TestCase\Model\Behavior;
 
 use Cake\Auth\PasswordHasherFactory;
 use Cake\Core\Configure;
-use Cake\ORM\TableRegistry;
 use Shim\TestSuite\TestCase;
 
 class PasswordableBehaviorTest extends TestCase {
@@ -38,7 +37,7 @@ class PasswordableBehaviorTest extends TestCase {
 		Configure::delete('Passwordable');
 		Configure::write('Passwordable.auth', 'AuthTest');
 
-		$this->Users = TableRegistry::getTableLocator()->get('ToolsUsers');
+		$this->Users = $this->getTableLocator()->get('ToolsUsers');
 
 		$this->hasher = PasswordHasherFactory::build('Default');
 	}
@@ -47,7 +46,7 @@ class PasswordableBehaviorTest extends TestCase {
 	 * @return void
 	 */
 	public function tearDown(): void {
-		TableRegistry::clear();
+		$this->getTableLocator()->clear();
 
 		parent::tearDown();
 	}

+ 2 - 3
tests/TestCase/Model/Behavior/ResetBehaviorTest.php

@@ -2,7 +2,6 @@
 
 namespace Tools\Test\TestCase\Model\Behavior;
 
-use Cake\ORM\TableRegistry;
 use Shim\TestSuite\TestCase;
 use TestApp\Model\Table\ResetCommentsTable;
 
@@ -31,7 +30,7 @@ class ResetBehaviorTest extends TestCase {
 	public function setUp(): void {
 		parent::setUp();
 
-		$this->Table = TableRegistry::getTableLocator()->get('ResetComments');
+		$this->Table = $this->getTableLocator()->get('ResetComments');
 		$this->Table->addBehavior('Tools.Reset');
 	}
 
@@ -39,7 +38,7 @@ class ResetBehaviorTest extends TestCase {
 	 * @return void
 	 */
 	public function tearDown(): void {
-		TableRegistry::clear();
+		$this->getTableLocator()->clear();
 
 		parent::tearDown();
 	}

+ 2 - 3
tests/TestCase/Model/Behavior/SluggedBehaviorTest.php

@@ -4,7 +4,6 @@ namespace Tools\Test\TestCase\Model\Behavior;
 
 use Cake\Core\Configure;
 use Cake\ORM\Entity;
-use Cake\ORM\TableRegistry;
 use RuntimeException;
 use Shim\TestSuite\TestCase;
 use TestApp\Model\Entity\SluggedArticle;
@@ -39,7 +38,7 @@ class SluggedBehaviorTest extends TestCase {
 		//$this->connection = ConnectionManager::get('test');
 
 		$options = ['alias' => 'Articles'];
-		$this->articles = TableRegistry::getTableLocator()->get('SluggedArticles', $options);
+		$this->articles = $this->getTableLocator()->get('SluggedArticles', $options);
 		Configure::delete('Slugged');
 
 		$this->articles->addBehavior('Tools.Slugged');
@@ -53,7 +52,7 @@ class SluggedBehaviorTest extends TestCase {
 	public function tearDown(): void {
 		unset($this->articles);
 
- 		TableRegistry::clear();
+ 		$this->getTableLocator()->clear();
  		parent::tearDown();
 	}
 

+ 1 - 2
tests/TestCase/Model/Behavior/StringBehaviorTest.php

@@ -2,7 +2,6 @@
 
 namespace Tools\Test\TestCase\Model\Behavior;
 
-use Cake\ORM\TableRegistry;
 use Shim\TestSuite\TestCase;
 
 class StringBehaviorTest extends TestCase {
@@ -25,7 +24,7 @@ class StringBehaviorTest extends TestCase {
 	public function setUp(): void {
 		parent::setUp();
 
-		$this->Comments = TableRegistry::getTableLocator()->get('StringComments');
+		$this->Comments = $this->getTableLocator()->get('StringComments');
 		$this->Comments->addBehavior('Tools.String', ['fields' => ['title'], 'input' => ['ucfirst']]);
 	}
 

+ 1 - 2
tests/TestCase/Model/Behavior/ToggleBehaviorTest.php

@@ -2,7 +2,6 @@
 
 namespace Tools\Test\TestCase\Model\Behavior;
 
-use Cake\ORM\TableRegistry;
 use Shim\TestSuite\TestCase;
 
 class ToggleBehaviorTest extends TestCase {
@@ -25,7 +24,7 @@ class ToggleBehaviorTest extends TestCase {
 	public function setUp(): void {
 		parent::setUp();
 
-		$this->Addresses = TableRegistry::getTableLocator()->get('ToggleAddresses');
+		$this->Addresses = $this->getTableLocator()->get('ToggleAddresses');
 		$this->Addresses->addBehavior('Tools.Toggle', ['scopeFields' => 'category_id']);
 	}
 

+ 1 - 2
tests/TestCase/Model/Behavior/TypeMapBehaviorTest.php

@@ -2,7 +2,6 @@
 
 namespace Tools\Test\TestCase\Model\Behavior;
 
-use Cake\ORM\TableRegistry;
 use Shim\TestSuite\TestCase;
 
 class TypeMapBehaviorTest extends TestCase {
@@ -37,7 +36,7 @@ class TypeMapBehaviorTest extends TestCase {
 	 * @return void
 	 */
 	public function testFields() {
-		$this->Table = TableRegistry::getTableLocator()->get('Data');
+		$this->Table = $this->getTableLocator()->get('Data');
 		$this->Table->addBehavior('Tools.Jsonable', ['fields' => ['data_array']]);
 
 		$entity = $this->Table->newEmptyEntity();

+ 1 - 2
tests/TestCase/Model/Behavior/TypographicBehaviorTest.php

@@ -2,7 +2,6 @@
 
 namespace Tools\Test\TestCase\Model\Behavior;
 
-use Cake\ORM\TableRegistry;
 use Shim\TestSuite\TestCase;
 use Tools\Model\Behavior\TypographicBehavior;
 
@@ -26,7 +25,7 @@ class TypographicBehaviorTest extends TestCase {
 	public function setUp(): void {
 		parent::setUp();
 
-		$this->Model = TableRegistry::getTableLocator()->get('Articles');
+		$this->Model = $this->getTableLocator()->get('Articles');
 		$this->Model->addBehavior('Tools.Typographic', ['fields' => ['body'], 'before' => 'marshal']);
 	}
 

+ 2 - 3
tests/TestCase/Model/Entity/EntityTest.php

@@ -2,7 +2,6 @@
 
 namespace Tools\Test\TestCase\Model\Entity;
 
-use Cake\ORM\TableRegistry;
 use Shim\TestSuite\TestCase;
 use Tools\Model\Entity\Entity;
 
@@ -27,14 +26,14 @@ class EntityTest extends TestCase {
 	public function setUp(): void {
 		parent::setUp();
 
-		$this->Users = TableRegistry::getTableLocator()->get('ToolsUsers');
+		$this->Users = $this->getTableLocator()->get('ToolsUsers');
 	}
 
 	/**
 	 * @return void
 	 */
 	public function tearDown(): void {
-		TableRegistry::clear();
+		$this->getTableLocator()->clear();
 
 		parent::tearDown();
 	}

+ 4 - 6
tests/TestCase/Model/Table/TableTest.php

@@ -2,9 +2,7 @@
 
 namespace Tools\Test\TestCase\Model\Table;
 
-use Cake\Datasource\ConnectionManager;
 use Cake\I18n\Time;
-use Cake\ORM\TableRegistry;
 use Cake\Utility\Hash;
 use Shim\TestSuite\TestCase;
 
@@ -38,9 +36,9 @@ class TableTest extends TestCase {
 	public function setUp(): void {
 		parent::setUp();
 
-		$this->Users = TableRegistry::getTableLocator()->get('ToolsUsers');
+		$this->Users = $this->getTableLocator()->get('ToolsUsers');
 
-		$this->Posts = TableRegistry::getTableLocator()->get('Posts');
+		$this->Posts = $this->getTableLocator()->get('Posts');
 		$this->Posts->belongsTo('Authors');
 	}
 
@@ -48,7 +46,7 @@ class TableTest extends TestCase {
 	 * @return void
 	 */
 	public function tearDown(): void {
-		TableRegistry::clear();
+		$this->getTableLocator()->clear();
 
 		parent::tearDown();
 	}
@@ -69,7 +67,7 @@ class TableTest extends TestCase {
 	 * @return void
 	 */
 	public function testTimestamp() {
-		$this->Roles = TableRegistry::getTableLocator()->get('Roles');
+		$this->Roles = $this->getTableLocator()->get('Roles');
 		$entity = $this->Roles->newEntity(['name' => 'Foo', 'alias' => 'foo']);
 		$result = $this->Roles->save($entity);
 		$this->assertTrue(!empty($result['created']));

+ 10 - 2
tests/TestCase/Model/Table/TokensTableTest.php

@@ -2,7 +2,6 @@
 
 namespace Tools\Test\TestCase\Model\Table;
 
-use Cake\ORM\TableRegistry;
 use Shim\TestSuite\TestCase;
 use Tools\Model\Table\TokensTable;
 
@@ -26,7 +25,16 @@ class TokensTableTest extends TestCase {
 	public function setUp(): void {
 		parent::setUp();
 
-		$this->Tokens = TableRegistry::getTableLocator()->get('Tools.Tokens');
+		$this->Tokens = $this->getTableLocator()->get('Tools.Tokens');
+	}
+
+	/**
+	 * @return void
+	 */
+	public function tearDown(): void {
+		$this->getTableLocator()->clear();
+
+		parent::tearDown();
 	}
 
 	/**

+ 1 - 2
tests/TestCase/Utility/FileLogTest.php

@@ -2,7 +2,6 @@
 
 namespace Tools\Test\Utility;
 
-use Cake\ORM\TableRegistry;
 use Shim\TestSuite\TestCase;
 use Tools\Utility\FileLog;
 
@@ -144,7 +143,7 @@ class FileLogTest extends TestCase {
 		}
 
 		$result = FileLog::write(
-			TableRegistry::getTableLocator()->get('Posts'),
+			$this->getTableLocator()->get('Posts'),
 			static::TEST_FILENAME_OBJECT
 		);
 

+ 2 - 3
tests/TestCase/View/Helper/TreeHelperTest.php

@@ -4,7 +4,6 @@ namespace Tools\Test\TestCase\View\Helper;
 
 use Cake\Datasource\ConnectionManager;
 use Cake\ORM\Entity;
-use Cake\ORM\TableRegistry;
 use Cake\View\View;
 use Shim\TestSuite\TestCase;
 use Tools\View\Helper\TreeHelper;
@@ -47,7 +46,7 @@ class TreeHelperTest extends TestCase {
 		parent::setUp();
 
 		$this->Tree = new TreeHelper(new View(null));
-		$this->Table = TableRegistry::getTableLocator()->get('AfterTrees');
+		$this->Table = $this->getTableLocator()->get('AfterTrees');
 		$this->Table->addBehavior('Tree');
 
 		$connection = ConnectionManager::get('test');
@@ -82,7 +81,7 @@ class TreeHelperTest extends TestCase {
 	public function tearDown(): void {
 		unset($this->Table);
 
- 		TableRegistry::clear();
+ 		$this->getTableLocator()->clear();
 		parent::tearDown();
 	}