-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
253 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
namespace Tests\Support\Config; | ||
|
||
use \CodeIgniter\Config\BaseService; | ||
|
||
class MockServices extends BaseService | ||
{ | ||
|
||
public $psr4 = [ | ||
'Tests/Support' => TESTPATH . '_support/', | ||
]; | ||
public $classmap = []; | ||
|
||
//-------------------------------------------------------------------- | ||
|
||
public function __construct() | ||
{ | ||
// Don't call the parent since we don't want the default mappings. | ||
// parent::__construct(); | ||
} | ||
|
||
//-------------------------------------------------------------------- | ||
public static function locator(bool $getShared = true) | ||
{ | ||
return new \CodeIgniter\Autoloader\FileLocator(static::autoloader()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
namespace Tests\Support\Controllers; | ||
|
||
use CodeIgniter\API\ResponseTrait; | ||
use CodeIgniter\Controller; | ||
use CodeIgniter\HTTP\Exceptions\HTTPException; | ||
|
||
/** | ||
* This is a testing only controller, intended to blow up in multiple | ||
* ways to make sure we catch them. | ||
*/ | ||
class Popcorn extends Controller | ||
{ | ||
|
||
use ResponseTrait; | ||
|
||
public function index() | ||
{ | ||
return 'Hi there'; | ||
} | ||
|
||
public function pop() | ||
{ | ||
$this->respond('Oops', 567, 'Surprise'); | ||
} | ||
|
||
public function popper() | ||
{ | ||
throw new \RuntimeException('Surprise', 500); | ||
} | ||
|
||
public function weasel() | ||
{ | ||
$this->respond('', 200); | ||
} | ||
|
||
public function oops() | ||
{ | ||
$this->failUnauthorized(); | ||
} | ||
|
||
public function goaway() | ||
{ | ||
return redirect()->to('/'); | ||
} | ||
|
||
// @see https://github.com/codeigniter4/CodeIgniter4/issues/1834 | ||
public function index3() | ||
{ | ||
$response = $this->response->setJSON([ | ||
'lang' => $this->request->getLocale(), | ||
]); | ||
|
||
// echo var_dump($this->response->getBody()); | ||
return $response; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php namespace App\Controllers; | ||
|
||
/** | ||
* Class BaseController | ||
* | ||
* BaseController provides a convenient place for loading components | ||
* and performing functions that are needed by all your controllers. | ||
* Extend this class in any new controllers: | ||
* class Home extends BaseController | ||
* | ||
* For security be sure to declare any new methods as protected or private. | ||
* | ||
* @package CodeIgniter | ||
*/ | ||
|
||
use CodeIgniter\Controller; | ||
|
||
class BaseController extends Controller | ||
{ | ||
|
||
/** | ||
* An array of helpers to be loaded automatically upon | ||
* class instantiation. These helpers will be available | ||
* to all other controllers that extend BaseController. | ||
* | ||
* @var array | ||
*/ | ||
protected $helpers = [ ]; | ||
|
||
/** | ||
* Constructor. | ||
* | ||
*/ | ||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) | ||
{ | ||
// Do Not Edit This Line | ||
parent::initController($request, $response, $logger); | ||
|
||
//-------------------------------------------------------------------- | ||
// Preload any models, libraries, etc, here. | ||
//-------------------------------------------------------------------- | ||
// E.g.: | ||
// $this->session = \Config\Services::session(); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters