From 2a7c06e16fb33a193516c11ab598e4a197c67e5a Mon Sep 17 00:00:00 2001 From: Koji Tanaka Date: Sat, 7 Jan 2023 11:13:47 +0900 Subject: [PATCH] test: Replace PHPUnit's class name in tests Co-authored-by: Kenshin Okinaka --- lib/Cake/Test/Case/Cache/CacheTest.php | 2 +- .../Test/Case/Console/Command/SchemaShellTest.php | 2 +- .../Case/Console/Command/Task/ControllerTaskTest.php | 4 ++-- .../Test/Case/Console/Command/Task/ModelTaskTest.php | 2 +- .../Case/Console/Command/Task/PluginTaskTest.php | 12 ++++++------ .../Test/Case/Console/Command/Task/ViewTaskTest.php | 2 +- .../Case/Controller/Component/Acl/PhpAclTest.php | 3 ++- lib/Cake/Test/Case/Utility/FolderTest.php | 2 +- 8 files changed, 15 insertions(+), 14 deletions(-) diff --git a/lib/Cake/Test/Case/Cache/CacheTest.php b/lib/Cake/Test/Case/Cache/CacheTest.php index 3dd3a2692..3bd850217 100644 --- a/lib/Cake/Test/Case/Cache/CacheTest.php +++ b/lib/Cake/Test/Case/Cache/CacheTest.php @@ -410,7 +410,7 @@ class CacheTest extends CakeTestCase { try { Cache::write('fail', 'value', 'test_trigger'); $this->fail('No exception thrown'); - } catch (PHPUnit_Framework_Error $e) { + } catch (PHPUnit\Framework\Error\Error $e) { $this->assertTrue(true); } Cache::drop('test_trigger'); diff --git a/lib/Cake/Test/Case/Console/Command/SchemaShellTest.php b/lib/Cake/Test/Case/Console/Command/SchemaShellTest.php index 72def74ea..2c3a07de2 100644 --- a/lib/Cake/Test/Case/Console/Command/SchemaShellTest.php +++ b/lib/Cake/Test/Case/Console/Command/SchemaShellTest.php @@ -313,7 +313,7 @@ class SchemaShellTest extends CakeTestCase { $this->Shell->expects($this->once())->method('in')->will($this->returnValue('o')); $this->Shell->expects($this->at(2))->method('out') - ->with(new PHPUnit_Framework_Constraint_PCREMatch('/Schema file:\s[a-z\.]+\sgenerated/')); + ->with(new PHPUnit\Framework\Constraint\RegularExpression('/Schema file:\s[a-z\.]+\sgenerated/')); $this->Shell->Schema = $this->getMock('CakeSchema'); $this->Shell->Schema->path = TMP; diff --git a/lib/Cake/Test/Case/Console/Command/Task/ControllerTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/ControllerTaskTest.php index d18e59d77..e9fbc57a6 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/ControllerTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/ControllerTaskTest.php @@ -307,7 +307,7 @@ class ControllerTaskTest extends CakeTestCase { $this->Task->expects($this->at(1))->method('createFile')->with( $path, - new PHPUnit_Framework_Constraint_IsAnything() + new \PHPUnit\Framework\Constraint\IsAnything() ); $this->Task->expects($this->at(3))->method('createFile')->with( $path, @@ -571,7 +571,7 @@ class ControllerTaskTest extends CakeTestCase { $this->Task->params = array('public' => true); $filename = '/my/path/BakeArticlesController.php'; - $expected = new PHPUnit_Framework_Constraint_Not($this->stringContains('$scaffold')); + $expected = new PHPUnit\Framework\Constraint\LogicalNot($this->stringContains('$scaffold')); $this->Task->expects($this->once())->method('createFile')->with( $filename, $expected ); diff --git a/lib/Cake/Test/Case/Console/Command/Task/ModelTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/ModelTaskTest.php index 8b5e1734d..2df4980d0 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/ModelTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/ModelTaskTest.php @@ -528,7 +528,7 @@ class ModelTaskTest extends CakeTestCase { 'two' => array(), 'key' => array('key' => 'primary') ); - $anything = new PHPUnit_Framework_Constraint_IsAnything(); + $anything = new \PHPUnit\Framework\Constraint\IsAnything(); $this->Task->expects($this->once())->method('in') ->with($anything, null, 'key') ->will($this->returnValue('my_field')); diff --git a/lib/Cake/Test/Case/Console/Command/Task/PluginTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/PluginTaskTest.php index a97e81c3a..c5e879d18 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/PluginTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/PluginTaskTest.php @@ -92,12 +92,12 @@ class PluginTaskTest extends CakeTestCase { $file = $path . DS . 'Controller' . DS . 'BakeTestPluginAppController.php'; $this->Task->expects($this->at(2)) ->method('createFile') - ->with($file, new PHPUnit_Framework_Constraint_IsAnything()); + ->with($file, new \PHPUnit\Framework\Constraint\IsAnything()); $file = $path . DS . 'Model' . DS . 'BakeTestPluginAppModel.php'; $this->Task->expects($this->at(3)) ->method('createFile') - ->with($file, new PHPUnit_Framework_Constraint_IsAnything()); + ->with($file, new \PHPUnit\Framework\Constraint\IsAnything()); $this->Task->bake('BakeTestPlugin'); @@ -148,11 +148,11 @@ class PluginTaskTest extends CakeTestCase { $file = $path . DS . 'Controller' . DS . 'TestPluginAppController.php'; $this->Task->expects($this->at(3))->method('createFile') - ->with($file, new PHPUnit_Framework_Constraint_IsAnything()); + ->with($file, $this->anything()); $file = $path . DS . 'Model' . DS . 'TestPluginAppModel.php'; $this->Task->expects($this->at(4))->method('createFile') - ->with($file, new PHPUnit_Framework_Constraint_IsAnything()); + ->with($file, $this->anything()); $this->Task->args = array(); $this->Task->execute(); @@ -175,12 +175,12 @@ class PluginTaskTest extends CakeTestCase { $path = $this->Task->path . 'BakeTestPlugin'; $file = $path . DS . 'Controller' . DS . 'BakeTestPluginAppController.php'; $this->Task->expects($this->at(2))->method('createFile') - ->with($file, new PHPUnit_Framework_Constraint_IsAnything()); + ->with($file, new \PHPUnit\Framework\Constraint\IsAnything()); $path = $this->Task->path . 'BakeTestPlugin'; $file = $path . DS . 'Model' . DS . 'BakeTestPluginAppModel.php'; $this->Task->expects($this->at(3))->method('createFile') - ->with($file, new PHPUnit_Framework_Constraint_IsAnything()); + ->with($file, new \PHPUnit\Framework\Constraint\IsAnything()); $this->Task->args = array('BakeTestPlugin'); diff --git a/lib/Cake/Test/Case/Console/Command/Task/ViewTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/ViewTaskTest.php index f9f2947cb..639e84921 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/ViewTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/ViewTaskTest.php @@ -310,7 +310,7 @@ class ViewTaskTest extends CakeTestCase { $this->Task->expects($this->at(0))->method('createFile') ->with( TMP . 'ViewTaskComments' . DS . 'edit.ctp', - new PHPUnit_Framework_Constraint_IsAnything() + new \PHPUnit\Framework\Constraint\IsAnything() ); $this->Task->bake('edit', true); } diff --git a/lib/Cake/Test/Case/Controller/Component/Acl/PhpAclTest.php b/lib/Cake/Test/Case/Controller/Component/Acl/PhpAclTest.php index 8080a62c3..07bfdc037 100644 --- a/lib/Cake/Test/Case/Controller/Component/Acl/PhpAclTest.php +++ b/lib/Cake/Test/Case/Controller/Component/Acl/PhpAclTest.php @@ -342,7 +342,8 @@ class PhpAclTest extends CakeTestCase { ), ); - $this->expectError('PHPUnit_Framework_Error', 'cycle detected' /* ... */); + $this->expectError(); + $this->expectErrorMessage('cycle detected'); $this->PhpAcl->build($config); } diff --git a/lib/Cake/Test/Case/Utility/FolderTest.php b/lib/Cake/Test/Case/Utility/FolderTest.php index 2c4a82d9a..800aa1f79 100644 --- a/lib/Cake/Test/Case/Utility/FolderTest.php +++ b/lib/Cake/Test/Case/Utility/FolderTest.php @@ -260,7 +260,7 @@ class FolderTest extends CakeTestCase { $Folder = new Folder($path); $result = $Folder->create($path . DS . 'two' . DS . 'three'); $this->assertFalse($result); - } catch (PHPUnit_Framework_Error $e) { + } catch (\PHPUnit\Framework\Error\Error $e) { $this->assertTrue(true); }