ソースを参照

Fix up class usage.

mscherer 7 年 前
コミット
514b961498

+ 6 - 5
tests/TestCase/ORM/AssociationTest.php

@@ -18,6 +18,7 @@ namespace Cake\Test\TestCase\ORM;
 use Cake\Core\Configure;
 use Cake\Core\Configure;
 use Cake\ORM\Table;
 use Cake\ORM\Table;
 use Cake\TestSuite\TestCase;
 use Cake\TestSuite\TestCase;
+use TestApp\Model\Table\AuthorsTable;
 use TestApp\Model\Table\TestTable;
 use TestApp\Model\Table\TestTable;
 
 
 /**
 /**
@@ -136,8 +137,8 @@ class AssociationTest extends TestCase
     public function testSetClassNameBeforeTarget()
     public function testSetClassNameBeforeTarget()
     {
     {
         $this->assertEquals(TestTable::class, $this->association->getClassName());
         $this->assertEquals(TestTable::class, $this->association->getClassName());
-        $this->assertSame($this->association, $this->association->setClassName('\TestApp\Model\Table\AuthorsTable'));
-        $this->assertEquals('\TestApp\Model\Table\AuthorsTable', $this->association->getClassName());
+        $this->assertSame($this->association, $this->association->setClassName(AuthorsTable::class));
+        $this->assertEquals(AuthorsTable::class, $this->association->getClassName());
     }
     }
 
 
     /**
     /**
@@ -148,9 +149,9 @@ class AssociationTest extends TestCase
     public function testSetClassNameAfterTarget()
     public function testSetClassNameAfterTarget()
     {
     {
         $this->expectException(\InvalidArgumentException::class);
         $this->expectException(\InvalidArgumentException::class);
-        $this->expectExceptionMessage('The class name "\TestApp\Model\Table\AuthorsTable" doesn\'t match the target table class name of');
+        $this->expectExceptionMessage('The class name "' . AuthorsTable::class . '" doesn\'t match the target table class name of');
         $this->association->getTarget();
         $this->association->getTarget();
-        $this->association->setClassName('\TestApp\Model\Table\AuthorsTable');
+        $this->association->setClassName(AuthorsTable::class);
     }
     }
 
 
     /**
     /**
@@ -187,7 +188,7 @@ class AssociationTest extends TestCase
     {
     {
         Configure::write('App.namespace', 'TestApp');
         Configure::write('App.namespace', 'TestApp');
 
 
-        $this->association->setClassName('\TestApp\Model\Table\AuthorsTable');
+        $this->association->setClassName(AuthorsTable::class);
         $className = get_class($this->association->getTarget());
         $className = get_class($this->association->getTarget());
         $this->assertEquals('TestApp\Model\Table\AuthorsTable', $className);
         $this->assertEquals('TestApp\Model\Table\AuthorsTable', $className);
         $this->association->setClassName('Authors');
         $this->association->setClassName('Authors');

+ 4 - 3
tests/TestCase/ORM/Behavior/TranslateBehaviorTest.php

@@ -23,6 +23,7 @@ use Cake\ORM\Locator\TableLocator;
 use Cake\TestSuite\TestCase;
 use Cake\TestSuite\TestCase;
 use Cake\Validation\Validator;
 use Cake\Validation\Validator;
 use TestApp\Model\Entity\TranslateArticle;
 use TestApp\Model\Entity\TranslateArticle;
+use TestApp\Model\Table\I18nTable;
 
 
 /**
 /**
  * Translate behavior test case
  * Translate behavior test case
@@ -81,15 +82,15 @@ class TranslateBehaviorTest extends TestCase
         $table = $this->getTableLocator()->get('Articles');
         $table = $this->getTableLocator()->get('Articles');
 
 
         $table->addBehavior('Translate', [
         $table->addBehavior('Translate', [
-            'translationTable' => '\TestApp\Model\Table\I18nTable',
+            'translationTable' => I18nTable::class,
             'fields' => ['title', 'body'],
             'fields' => ['title', 'body'],
         ]);
         ]);
 
 
         $items = $table->associations();
         $items = $table->associations();
         $i18n = $items->getByProperty('_i18n');
         $i18n = $items->getByProperty('_i18n');
 
 
-        $this->assertEquals('\TestApp\Model\Table\I18nTable', $i18n->getName());
-        $this->assertInstanceOf('TestApp\Model\Table\I18nTable', $i18n->getTarget());
+        $this->assertEquals(I18nTable::class, $i18n->getName());
+        $this->assertInstanceOf(I18nTable::class, $i18n->getTarget());
         $this->assertEquals('test_custom_i18n_datasource', $i18n->getTarget()->getConnection()->configName());
         $this->assertEquals('test_custom_i18n_datasource', $i18n->getTarget()->getConnection()->configName());
         $this->assertEquals('custom_i18n_table', $i18n->getTarget()->getTable());
         $this->assertEquals('custom_i18n_table', $i18n->getTarget()->getTable());
     }
     }

+ 2 - 1
tests/TestCase/ORM/TableTest.php

@@ -41,6 +41,7 @@ use Cake\TestSuite\TestCase;
 use Cake\Validation\Validator;
 use Cake\Validation\Validator;
 use InvalidArgumentException;
 use InvalidArgumentException;
 use TestApp\Model\Entity\ProtectedEntity;
 use TestApp\Model\Entity\ProtectedEntity;
+use TestApp\Model\Entity\VirtualUser;
 use TestApp\Model\Table\UsersTable;
 use TestApp\Model\Table\UsersTable;
 
 
 /**
 /**
@@ -1322,7 +1323,7 @@ class TableTest extends TestCase
         $table = new Table([
         $table = new Table([
             'table' => 'users',
             'table' => 'users',
             'connection' => $this->connection,
             'connection' => $this->connection,
-            'entityClass' => '\TestApp\Model\Entity\VirtualUser',
+            'entityClass' => VirtualUser::class,
         ]);
         ]);
         $table->setDisplayField('bonus');
         $table->setDisplayField('bonus');
 
 

+ 7 - 6
tests/TestCase/TestSuite/TestCaseTest.php

@@ -20,6 +20,7 @@ use Cake\Event\Event;
 use Cake\Event\EventList;
 use Cake\Event\EventList;
 use Cake\Event\EventManager;
 use Cake\Event\EventManager;
 use Cake\ORM\Entity;
 use Cake\ORM\Entity;
+use Cake\ORM\Table;
 use Cake\Test\Fixture\FixturizedTestCase;
 use Cake\Test\Fixture\FixturizedTestCase;
 use Cake\TestSuite\Fixture\FixtureManager;
 use Cake\TestSuite\Fixture\FixtureManager;
 use Cake\TestSuite\TestCase;
 use Cake\TestSuite\TestCase;
@@ -423,11 +424,11 @@ class TestCaseTest extends TestCase
         $Mock = $this->getMockForModel(
         $Mock = $this->getMockForModel(
             'Table',
             'Table',
             ['save'],
             ['save'],
-            ['alias' => 'Comments', 'className' => 'Cake\ORM\Table']
+            ['alias' => 'Comments', 'className' => Table::class]
         );
         );
 
 
         $result = $this->getTableLocator()->get('Comments');
         $result = $this->getTableLocator()->get('Comments');
-        $this->assertInstanceOf('Cake\ORM\Table', $result);
+        $this->assertInstanceOf(Table::class, $result);
         $this->assertEquals('Comments', $Mock->getAlias());
         $this->assertEquals('Comments', $Mock->getAlias());
 
 
         $Mock->expects($this->at(0))
         $Mock->expects($this->at(0))
@@ -444,19 +445,19 @@ class TestCaseTest extends TestCase
         $allMethodsStubs = $this->getMockForModel(
         $allMethodsStubs = $this->getMockForModel(
             'Table',
             'Table',
             [],
             [],
-            ['alias' => 'Comments', 'className' => '\Cake\ORM\Table']
+            ['alias' => 'Comments', 'className' => Table::class]
         );
         );
         $result = $this->getTableLocator()->get('Comments');
         $result = $this->getTableLocator()->get('Comments');
-        $this->assertInstanceOf('Cake\ORM\Table', $result);
+        $this->assertInstanceOf(Table::class, $result);
         $this->assertEmpty([], $allMethodsStubs->getAlias());
         $this->assertEmpty([], $allMethodsStubs->getAlias());
 
 
         $allMethodsMocks = $this->getMockForModel(
         $allMethodsMocks = $this->getMockForModel(
             'Table',
             'Table',
             null,
             null,
-            ['alias' => 'Comments', 'className' => '\Cake\ORM\Table']
+            ['alias' => 'Comments', 'className' => Table::class]
         );
         );
         $result = $this->getTableLocator()->get('Comments');
         $result = $this->getTableLocator()->get('Comments');
-        $this->assertInstanceOf('Cake\ORM\Table', $result);
+        $this->assertInstanceOf(Table::class, $result);
         $this->assertEquals('Comments', $allMethodsMocks->getAlias());
         $this->assertEquals('Comments', $allMethodsMocks->getAlias());
 
 
         $this->assertNotEquals($allMethodsStubs, $allMethodsMocks);
         $this->assertNotEquals($allMethodsStubs, $allMethodsMocks);

+ 7 - 1
tests/TestCase/View/HelperRegistryTest.php

@@ -16,6 +16,7 @@ declare(strict_types=1);
 namespace Cake\Test\TestCase\View;
 namespace Cake\Test\TestCase\View;
 
 
 use Cake\TestSuite\TestCase;
 use Cake\TestSuite\TestCase;
+use Cake\View\Helper\FormHelper;
 use Cake\View\Helper\HtmlHelper;
 use Cake\View\Helper\HtmlHelper;
 use Cake\View\HelperRegistry;
 use Cake\View\HelperRegistry;
 use Cake\View\View;
 use Cake\View\View;
@@ -38,6 +39,11 @@ class HelperRegistryTest extends TestCase
     public $Events;
     public $Events;
 
 
     /**
     /**
+     * @var \Cake\View\View
+     */
+    public $View;
+
+    /**
      * setUp
      * setUp
      *
      *
      * @return void
      * @return void
@@ -88,7 +94,7 @@ class HelperRegistryTest extends TestCase
         $this->assertInstanceOf(HtmlHelper::class, $result);
         $this->assertInstanceOf(HtmlHelper::class, $result);
 
 
         $result = $this->Helpers->Form;
         $result = $this->Helpers->Form;
-        $this->assertInstanceOf('Cake\View\Helper\FormHelper', $result);
+        $this->assertInstanceOf(FormHelper::class, $result);
 
 
         $this->View->setPlugin('TestPlugin');
         $this->View->setPlugin('TestPlugin');
         $this->loadPlugins(['TestPlugin']);
         $this->loadPlugins(['TestPlugin']);