Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions system/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ function log_message(string $level, $message, array $context = [])
// for asserting that logs were called in the test code.
if (ENVIRONMENT == 'testing')
{
$logger = new TestLogger(new \Config\Logger());
$logger = new \CodeIgniter\Log\TestLogger(new \Config\Logger());
return $logger->log($level, $message, $context);
}

return \Config\Services::logger(true)
->log($level, $message, $context);
->log($level, $message, $context);
}
}

Expand Down
2 changes: 1 addition & 1 deletion system/Config/AutoloadConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public function __construct()
'CodeIgniter\View\RenderableInterface' => BASEPATH.'View/RenderableInterface.php',
'CodeIgniter\View\View' => BASEPATH.'View/View.php',
'Zend\Escaper\Escaper' => BASEPATH.'View/Escaper.php',
'TestLogger' => BASEPATH.'../tests/_support/Log/TestLogger.php',
'CodeIgniter\Log\TestLogger' => BASEPATH.'../tests/_support/Log/TestLogger.php',
];
}

Expand Down
8 changes: 5 additions & 3 deletions tests/Autoloader/AutoloaderTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
<?php namespace CodeIgniter\Autoloader;

class MockAutoloaderClass extends \CodeIgniter\Autoloader\Autoloader
class MockAutoloaderClass extends Autoloader
{

protected $files = [];
Expand All @@ -24,6 +24,8 @@ protected function requireFile($file)

}

use Config\Autoload;

//--------------------------------------------------------------------

class AutoloaderTest extends \CIUnitTestCase
Expand All @@ -35,7 +37,7 @@ class AutoloaderTest extends \CIUnitTestCase

protected function setUp()
{
$config = new Config\Autoload();
$config = new Autoload();

$config->classmap = [
'FirstClass' => '/app/dir/First.php',
Expand Down
11 changes: 5 additions & 6 deletions tests/Config/DotEnvTest.php
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
<?php
<?php namespace CodeIgniter\Config;

//require_once 'system/Benchmark/Timer.php';

use CodeIgniter\Config\DotEnv;

class DotEnvTest extends CIUnitTestCase {
class DotEnvTest extends \CIUnitTestCase
{

protected $fixturesFolder;

//--------------------------------------------------------------------

public function setup()
{
$this->fixturesFolder = dirname(__FILE__).'/fixtures';
$this->fixturesFolder = dirname(__FILE__).'/fixtures';
}

//--------------------------------------------------------------------

public function testReturnsFalseIfCannotFindFile()
{
$dotenv = new DotEnv(__DIR__);
$dotenv = new DotEnv(__DIR__);
$this->assertFalse($dotenv->load());
}

Expand Down
37 changes: 18 additions & 19 deletions tests/Config/MimesTest.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
<?php
<?php namespace Config;


class MimesTest extends CIUnitTestCase
class MimesTest extends \CIUnitTestCase
{
public function extensionsList()
{
return [
'null' => [null, 'xkadjflkjdsf'],
'single' => ['cpt', 'application/mac-compactpro'],
'trimmed' => ['cpt', ' application/mac-compactpro '],
'manyMimes' => ['csv', 'text/csv'],
'mixedCase' => ['csv', 'text/CSV'],
];
return [
'null' => [null, 'xkadjflkjdsf'],
'single' => ['cpt', 'application/mac-compactpro'],
'trimmed' => ['cpt', ' application/mac-compactpro '],
'manyMimes' => ['csv', 'text/csv'],
'mixedCase' => ['csv', 'text/CSV'],
];
}

//--------------------------------------------------------------------
Expand All @@ -24,20 +23,20 @@ public function extensionsList()
*/
public function testGuessExtensionFromType($expected, $mime)
{
$this->assertEquals($expected, \Config\Mimes::guessExtensionFromType($mime));
$this->assertEquals($expected, Mimes::guessExtensionFromType($mime));
}

//--------------------------------------------------------------------

public function mimesList()
{
return [
'null' => [null, 'xalkjdlfkj'],
'single' => ['audio/midi', 'mid'],
'many' => ['image/bmp', 'bmp'],
'trimmed' => ['image/bmp', '.bmp'],
'mixedCase' => ['image/bmp', 'BMP'],
];
return [
'null' => [null, 'xalkjdlfkj'],
'single' => ['audio/midi', 'mid'],
'many' => ['image/bmp', 'bmp'],
'trimmed' => ['image/bmp', '.bmp'],
'mixedCase' => ['image/bmp', 'BMP'],
];
}

//--------------------------------------------------------------------
Expand All @@ -47,7 +46,7 @@ public function mimesList()
*/
public function testGuessTypeFromExtension($expected, $ext)
{
$this->assertEquals($expected, \Config\Mimes::guessTypeFromExtension($ext));
$this->assertEquals($expected, Mimes::guessTypeFromExtension($ext));
}

//--------------------------------------------------------------------
Expand Down
13 changes: 6 additions & 7 deletions tests/Debug/TimerTest.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?php
<?php namespace CodeIgniter\Debug;

use CodeIgniter\Debug\Timer;

class TimerTest extends CIUnitTestCase {
class TimerTest extends \CIUnitTestCase
{

public function setUp() { }

Expand All @@ -19,7 +18,7 @@ public function tearDown() { }
*/
public function testStoresTimers()
{
$timer = new Timer();
$timer = new Timer();

$timer->start('test1');
sleep(1);
Expand Down Expand Up @@ -77,12 +76,12 @@ public function testElapsedTimeGivesSameResultAsTimersArray()
*/
public function testThrowsExceptionStoppingNonTimer()
{
$timer = new Timer();
$timer = new Timer();

$timer->stop('test1');
}

//--------------------------------------------------------------------


}
}
16 changes: 7 additions & 9 deletions tests/HTTP/CURLRequestTest.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php
<?php namespace CodeIgniter\HTTP;

use Config\App;
use CodeIgniter\HTTP\URI;
use CodeIgniter\HTTP\Response;

/**
* Class MockCURLRequest
Expand All @@ -11,8 +9,8 @@
* test runs. Instead, we can set the desired output
* and get back the set options.
*/
class MockCURLRequest extends \CodeIgniter\HTTP\CURLRequest {

class MockCURLRequest extends CURLRequest
{
public $curl_options;

protected $output = '';
Expand Down Expand Up @@ -43,7 +41,7 @@ protected function sendRequest(array $curl_options = []): string
//--------------------------------------------------------------------


class CURLRequestTest extends CIUnitTestCase
class CURLRequestTest extends \CIUnitTestCase
{
protected $request;

Expand All @@ -58,8 +56,8 @@ public function testSendReturnsResponse()
{
$output = "Howdy Stranger.";

$response = $this->request->setOutput($output)
->send('get', 'http://example.com');
$response = $this->request->setOutput($output)
->send('get', 'http://example.com');

$this->assertInstanceOf('CodeIgniter\\HTTP\\Response', $response);
$this->assertEquals($output, $response->getBody());
Expand All @@ -69,7 +67,7 @@ public function testSendReturnsResponse()

public function testGetSetsCorrectMethod()
{
$response = $this->request->get('http://example.com');
$response = $this->request->get('http://example.com');

$this->assertEquals('get', $this->request->getMethod());

Expand Down
42 changes: 21 additions & 21 deletions tests/HTTP/Files/FileCollectionTest.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?php
<?php namespace CodeIgniter\HTTP\Files;

class FileCollectionTest extends CIUnitTestCase
class FileCollectionTest extends \CIUnitTestCase
{
public function setUp()
{
$_FILES = [];
$_FILES = [];
}

//--------------------------------------------------------------------

public function testAllReturnsNullWithNoFiles()
{
$files = new \CodeIgniter\HTTP\Files\FileCollection();
$files = new FileCollection();

$this->assertNull($files->all());
}
Expand All @@ -23,19 +23,19 @@ public function testAllReturnsValidSingleFile()
$_FILES = [
'userfile' => [
'name' => 'someFile.txt',
'type' => 'text/plain',
'size' => '124',
'tmp_name' => '/tmp/myTempFile.txt',
'error' => 0
'type' => 'text/plain',
'size' => '124',
'tmp_name' => '/tmp/myTempFile.txt',
'error' => 0
]
];

$collection = new \CodeIgniter\HTTP\Files\FileCollection();
$collection = new FileCollection();
$files = $collection->all();
$this->assertEquals(1, count($files));

$file = array_shift($files);
$this->assertTrue($file instanceof \CodeIgniter\HTTP\Files\UploadedFile);
$this->assertTrue($file instanceof UploadedFile);

$this->assertEquals('someFile.txt', $file->getName());
$this->assertEquals(124, $file->getSize());
Expand All @@ -55,7 +55,7 @@ public function testAllReturnsValidMultipleFilesSameName()
]
];

$collection = new \CodeIgniter\HTTP\Files\FileCollection();
$collection = new FileCollection();
$files = $collection->all();
$this->assertEquals(1, count($files));
$this->assertEquals('userfile', key($files));
Expand All @@ -64,7 +64,7 @@ public function testAllReturnsValidMultipleFilesSameName()
$this->assertEquals(2, count($files));

$file = $files[0];
$this->assertTrue($file instanceof \CodeIgniter\HTTP\Files\UploadedFile);
$this->assertTrue($file instanceof UploadedFile);

$this->assertEquals('fileA.txt', $file->getName());
$this->assertEquals('/tmp/fileA.txt', $file->getTempName());
Expand Down Expand Up @@ -95,13 +95,13 @@ public function testAllReturnsValidMultipleFilesDifferentName()
],
];

$collection = new \CodeIgniter\HTTP\Files\FileCollection();
$collection = new FileCollection();
$files = $collection->all();
$this->assertEquals(2, count($files));
$this->assertEquals('userfile1', key($files));

$file = array_shift($files);
$this->assertTrue($file instanceof \CodeIgniter\HTTP\Files\UploadedFile);
$this->assertTrue($file instanceof UploadedFile);

$this->assertEquals('fileA.txt', $file->getName());
$this->assertEquals('/tmp/fileA.txt', $file->getTempName());
Expand All @@ -110,7 +110,7 @@ public function testAllReturnsValidMultipleFilesDifferentName()
$this->assertEquals(124, $file->getSize());

$file = array_pop($files);
$this->assertTrue($file instanceof \CodeIgniter\HTTP\Files\UploadedFile);
$this->assertTrue($file instanceof UploadedFile);

$this->assertEquals('fileB.txt', $file->getName());
$this->assertEquals('/tmp/fileB.txt', $file->getTempName());
Expand Down Expand Up @@ -152,15 +152,15 @@ public function testAllReturnsValidSingleFileNestedName()
]
];

$collection = new \CodeIgniter\HTTP\Files\FileCollection();
$collection = new FileCollection();
$files = $collection->all();
$this->assertEquals(1, count($files));
$this->assertEquals('userfile', key($files));

$this->assertTrue(isset($files['userfile']['foo']['bar']));

$file = $files['userfile']['foo']['bar'];
$this->assertTrue($file instanceof \CodeIgniter\HTTP\Files\UploadedFile);
$this->assertTrue($file instanceof UploadedFile);

$this->assertEquals('fileA.txt', $file->getName());
$this->assertEquals('/tmp/fileA.txt', $file->getTempName());
Expand All @@ -183,7 +183,7 @@ public function testHasFileWithSingleFile()
]
];

$collection = new \CodeIgniter\HTTP\Files\FileCollection();
$collection = new FileCollection();

$this->assertTrue($collection->hasFile('userfile'));
$this->assertFalse($collection->hasFile('foo'));
Expand All @@ -210,7 +210,7 @@ public function testHasFileWithMultipleFilesWithDifferentNames()
],
];

$collection = new \CodeIgniter\HTTP\Files\FileCollection();
$collection = new FileCollection();

$this->assertTrue($collection->hasFile('userfile1'));
$this->assertTrue($collection->hasFile('userfile2'));
Expand Down Expand Up @@ -249,7 +249,7 @@ public function testHasFileWithSingleFileNestedName()
]
];

$collection = new \CodeIgniter\HTTP\Files\FileCollection();
$collection = new FileCollection();

$this->assertTrue($collection->hasFile('userfile'));
$this->assertTrue($collection->hasFile('userfile.foo'));
Expand All @@ -272,7 +272,7 @@ public function testErrorString()

$expected = 'The file "someFile.txt" exceeds your upload_max_filesize ini directive.';

$collection = new \CodeIgniter\HTTP\Files\FileCollection();
$collection = new FileCollection();
$file = $collection->getFile('userfile');

$this->assertEquals($expected, $file->getErrorString());
Expand Down
9 changes: 4 additions & 5 deletions tests/HTTP/HeaderTest.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<?php


class HeaderTest extends CIUnitTestCase {
<?php namespace CodeIgniter\HTTP;

class HeaderTest extends \CIUnitTestCase
{
public function testHeaderStoresBasics()
{
$name = 'foo';
$value = 'bar';

$header = new \CodeIgniter\HTTP\Header($name, $value);
$header = new \CodeIgniter\HTTP\Header($name, $value);

$this->assertEquals($name, $header->getName());
$this->assertEquals($value, $header->getValue());
Expand Down
Loading