mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
Undo the last bone-headed commit.
This commit is contained in:
parent
35d00b9cb2
commit
4872f0aac1
@ -53,7 +53,6 @@ class Autoload extends \CodeIgniter\Config\AutoloadConfig
|
||||
'Config' => APPPATH . 'Config',
|
||||
APP_NAMESPACE => APPPATH, // For custom namespace
|
||||
'App' => APPPATH, // To ensure filters, etc still found,
|
||||
'Vulcan' => ROOTPATH . '../vulcan/',
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -7,9 +7,6 @@ class Home extends BaseController
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$model = new UserModel();
|
||||
dd($model->findAll());
|
||||
|
||||
return view('welcome_message');
|
||||
}
|
||||
|
||||
|
@ -1,34 +0,0 @@
|
||||
<?php namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
/**
|
||||
* UserModel Model
|
||||
*/
|
||||
class UserModel extends Model
|
||||
{
|
||||
protected $table = 'users';
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
protected $allowedFields = [
|
||||
'name',
|
||||
'email',
|
||||
];
|
||||
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDeletes = false;
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
protected $dateFormat = 'datetime';
|
||||
|
||||
protected $validationRules = [
|
||||
'id' => 'integer|max_length[11]',
|
||||
'name' => 'alpha_numeric_spaces|max_length[255]',
|
||||
'email' => 'alpha_numeric_spaces|max_length[255]',
|
||||
|
||||
];
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
<?php namespace Test;
|
||||
|
||||
use App\Controllers\Home;
|
||||
use CodeIgniter\HTTP\IncomingRequest;
|
||||
use CodeIgniter\HTTP\Response;
|
||||
use CodeIgniter\Test\CIUnitTestCase;
|
||||
use CodeIgniter\Test\ControllerTester;
|
||||
|
||||
class ControllerTest extends CIUnitTestCase
|
||||
{
|
||||
use ControllerTester;
|
||||
|
||||
public function testHomePage()
|
||||
{
|
||||
$result = $this->withUri('http://localhost:8080')
|
||||
->controller(Home::class)
|
||||
->execute('index');
|
||||
|
||||
// Success Status
|
||||
$this->assertTrue($result->isOK());
|
||||
|
||||
// Not a Redirect
|
||||
$this->assertFalse($result->isRedirect());
|
||||
|
||||
$request = $result->request();
|
||||
$this->assertInstanceOf(IncomingRequest::class, $request);
|
||||
|
||||
$response = $result->response();
|
||||
$this->assertInstanceOf(Response::class, $response);
|
||||
|
||||
$body = $result->getBody();
|
||||
$this->assertNotEmpty($body);
|
||||
|
||||
// Check the content of the page
|
||||
$this->assertTrue($result->see('CodeIgniter'));
|
||||
|
||||
$this->assertTrue($result->dontSee('Laravel'));
|
||||
|
||||
$this->assertTrue($result->seeElement('.logo'));
|
||||
|
||||
$this->assertTrue($result->seeLink('User Guide'));
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
<?php namespace Test;
|
||||
|
||||
use CodeIgniter\Test\CIDatabaseTestCase;
|
||||
|
||||
class DatabaseTest extends CIDatabaseTestCase
|
||||
{
|
||||
public function testSomeThings()
|
||||
{
|
||||
$this->hasInDatabase('user', [
|
||||
'name' => 'Foo Bar',
|
||||
'email' => 'foobar@example.com',
|
||||
'country' => 'US',
|
||||
]);
|
||||
|
||||
$this->seeInDatabase('user', [
|
||||
'name' => 'Foo Bar',
|
||||
]);
|
||||
|
||||
$this->dontSeeInDatabase('user', [
|
||||
'name' => 'Fannie Farkle',
|
||||
]);
|
||||
|
||||
$name = $this->grabFromDatabase('user', 'name', ['email' => 'foobar@example.com']);
|
||||
$this->assertEquals('Foo Bar', $name);
|
||||
|
||||
$this->seeNumRecords(1, 'user', ['name' => 'Foo Bar']);
|
||||
}
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
<?php namespace Test;
|
||||
|
||||
use CodeIgniter\Test\FeatureTestCase;
|
||||
|
||||
class HomeTest extends FeatureTestCase
|
||||
{
|
||||
public function testHomePage()
|
||||
{
|
||||
$result = $this->skipEvents()->call('get', '/');
|
||||
|
||||
$result->assertOk();
|
||||
|
||||
$result->assertStatus(200);
|
||||
|
||||
$result->assertSee('CodeIgniter');
|
||||
$result->assertDontSee('Symfony');
|
||||
}
|
||||
|
||||
public function testJson()
|
||||
{
|
||||
$result = $this->get('api');
|
||||
|
||||
$json = $result->getJSON();
|
||||
|
||||
$result->assertJSONFragment(['foo' => 'bar']);
|
||||
$result->assertJSONExact([
|
||||
'foo' => 'bar',
|
||||
'bar' => 'none',
|
||||
]);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user