Skip to content

Commit 169d58e

Browse files
committed
Test typos changes
1 parent 1ed6d46 commit 169d58e

6 files changed

Lines changed: 28 additions & 18 deletions

File tree

system/Test/CIDatabaseTestCase.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737

3838
namespace CodeIgniter\Test;
3939

40+
use Config\Database;
41+
use Config\Migrations;
4042
use Config\Services;
4143
use CodeIgniter\Database\BaseConnection;
4244
use CodeIgniter\Database\MigrationRunner;
@@ -123,14 +125,14 @@ public function loadDependencies()
123125
{
124126
if ($this->db === null)
125127
{
126-
$this->db = \Config\Database::connect($this->DBGroup);
128+
$this->db = Database::connect($this->DBGroup);
127129
$this->db->initialize();
128130
}
129131

130132
if ($this->migrations === null)
131133
{
132134
// Ensure that we can run migrations
133-
$config = new \Config\Migrations();
135+
$config = new Migrations();
134136
$config->enabled = true;
135137

136138
$this->migrations = Services::migrations($config, $this->db);
@@ -139,7 +141,7 @@ public function loadDependencies()
139141

140142
if ($this->seeder === null)
141143
{
142-
$this->seeder = \Config\Database::seeder($this->DBGroup);
144+
$this->seeder = Database::seeder($this->DBGroup);
143145
$this->seeder->setSilent(true);
144146
}
145147
}
@@ -170,7 +172,7 @@ protected function setUp()
170172

171173
if (is_array($tables))
172174
{
173-
$forge = \Config\Database::forge('tests');
175+
$forge = Database::forge('tests');
174176

175177
foreach ($tables as $table)
176178
{

system/Test/CIUnitTestCase.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ protected function setUp()
7676
* @param string $level
7777
* @param null $expectedMessage
7878
*
79+
* @return bool
7980
* @throws \Exception
8081
*/
8182
public function assertLogged(string $level, $expectedMessage = null)
@@ -201,6 +202,7 @@ public function assertCloseEnough(int $expected, $actual, string $message = '',
201202
* @param string $message
202203
* @param integer $tolerance
203204
*
205+
* @return bool
204206
* @throws \Exception
205207
*/
206208
public function assertCloseEnoughString($expected, $actual, string $message = '', int $tolerance = 1)

system/Test/ControllerTester.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
use CodeIgniter\HTTP\URI;
4646
use Config\App;
4747
use Config\Services;
48+
use InvalidArgumentException;
49+
use Throwable;
4850

4951
/**
5052
* ControllerTester Trait
@@ -82,7 +84,7 @@ public function controller(string $name)
8284
{
8385
if (! class_exists($name))
8486
{
85-
throw new \InvalidArgumentException('Invalid Controller: ' . $name);
87+
throw new InvalidArgumentException('Invalid Controller: ' . $name);
8688
}
8789

8890
if (empty($this->appConfig))
@@ -123,7 +125,7 @@ public function execute(string $method, ...$params)
123125
{
124126
if (! method_exists($this->controller, $method) || ! is_callable([$this->controller, $method]))
125127
{
126-
throw new \InvalidArgumentException('Method does not exist or is not callable in controller: ' . $method);
128+
throw new InvalidArgumentException('Method does not exist or is not callable in controller: ' . $method);
127129
}
128130

129131
// The URL helper is always loaded by the system
@@ -141,7 +143,7 @@ public function execute(string $method, ...$params)
141143

142144
$response = $this->controller->{$method}(...$params);
143145
}
144-
catch (\Throwable $e)
146+
catch (Throwable $e)
145147
{
146148
$result->response()
147149
->setStatusCode($e->getCode());

system/Test/FeatureResponse.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939

4040
use CodeIgniter\HTTP\RedirectResponse;
4141
use CodeIgniter\HTTP\Response;
42+
use Config\Format;
4243
use PHPUnit\Framework\TestCase;
4344

4445
/**
@@ -226,10 +227,6 @@ public function assertCookie(string $key, $value = null, string $prefix = '')
226227
* Assert the Response does not have the specified cookie set.
227228
*
228229
* @param string $key
229-
* @param null $value
230-
* @param string $prefix
231-
*
232-
* @throws \Exception
233230
*/
234231
public function assertCookieMissing(string $key)
235232
{
@@ -379,7 +376,7 @@ public function assertJSONExact($test)
379376

380377
if (is_array($test))
381378
{
382-
$config = new \Config\Format();
379+
$config = new Format();
383380
$formatter = $config->getFormatter('application/json');
384381
$test = $formatter->format($test);
385382
}

system/Test/FeatureTestCase.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class FeatureTestCase extends CIDatabaseTestCase
8888
*/
8989
protected function withRoutes(array $routes = null)
9090
{
91-
$collection = \Config\Services::routes();
91+
$collection = Services::routes();
9292

9393
if ($routes)
9494
{
@@ -297,6 +297,7 @@ protected function setupRequest(string $method, string $path = null, array $para
297297
* @param array|null $params
298298
*
299299
* @return \CodeIgniter\HTTP\Request
300+
* @throws \ReflectionException
300301
*/
301302
protected function populateGlobals(string $method, Request $request, array $params = null)
302303
{

system/Test/ReflectionHelper.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,14 @@
4747
*/
4848
trait ReflectionHelper
4949
{
50-
5150
/**
5251
* Find a private method invoker.
5352
*
54-
* @param object|string $obj object or class name
55-
* @param string $method method name
53+
* @param object|string $obj object or class name
54+
* @param string $method method name
55+
*
5656
* @return \Closure
57+
* @throws \ReflectionException
5758
*/
5859
public static function getPrivateMethodInvoker($obj, $method)
5960
{
@@ -74,6 +75,7 @@ public static function getPrivateMethodInvoker($obj, $method)
7475
* @param string $property
7576
*
7677
* @return \ReflectionProperty
78+
* @throws \ReflectionException
7779
*/
7880
private static function getAccessibleRefProperty($obj, $property)
7981
{
@@ -98,6 +100,8 @@ private static function getAccessibleRefProperty($obj, $property)
98100
* @param object|string $obj object or class name
99101
* @param string $property property name
100102
* @param mixed $value value
103+
*
104+
* @throws \ReflectionException
101105
*/
102106
public static function setPrivateProperty($obj, $property, $value)
103107
{
@@ -108,9 +112,11 @@ public static function setPrivateProperty($obj, $property, $value)
108112
/**
109113
* Retrieve a private property.
110114
*
111-
* @param object|string $obj object or class name
112-
* @param string $property property name
115+
* @param object|string $obj object or class name
116+
* @param string $property property name
117+
*
113118
* @return mixed value
119+
* @throws \ReflectionException
114120
*/
115121
public static function getPrivateProperty($obj, $property)
116122
{

0 commit comments

Comments
 (0)