Skip to content

Commit

Permalink
整理测试用例
Browse files Browse the repository at this point in the history
  • Loading branch information
titrxw committed Apr 14, 2020
1 parent 42ab4e2 commit d50382b
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 13 deletions.
8 changes: 4 additions & 4 deletions tests/ExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ public function testMake() {
$command = $application->get('make:exception');
$command->run(new ArgvInput([
'input',
'--name=httpError',
'--name=httpErrorTest',
'--type=response'
]), ioutputer());

$this->assertSame(true, file_exists(APP_PATH . '/Exception/HttpErrorException.php'));
$this->assertStringContainsString('extends ResponseExceptionAbstract', file_get_contents(APP_PATH . '/Exception/HttpErrorException.php'));
$this->assertSame(true, file_exists(APP_PATH . '/Exception/HttpErrorTestException.php'));
$this->assertStringContainsString('extends ResponseExceptionAbstract', file_get_contents(APP_PATH . '/Exception/HttpErrorTestException.php'));

unlink(APP_PATH . '/Exception/HttpErrorException.php');
unlink(APP_PATH . '/Exception/HttpErrorTestException.php');
}

public function setUp(): void {
Expand Down
2 changes: 1 addition & 1 deletion tests/Model/EventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function testEvent() {
*/
$event = iloader()->get(EventDispatcher::class);
$event->listen(SavedEvent::class, SavedListener::class);

Schema::dropIfExists('user');
Schema::create('user', function (Blueprint $table) {
$table->bigIncrements('id');
$table->timestamps();
Expand Down
4 changes: 4 additions & 0 deletions tests/Model/TransactionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Test1Model extends ModelAbstract {

class TransactionTest extends ModelTestAbstract {
public function testSimple() {
idb()->connection()->getSchemaBuilder()->dropIfExists('test');
idb()->connection()->getSchemaBuilder()->create('test', function (Blueprint $table) {
$table->bigIncrements('id');
$table->timestamps();
Expand Down Expand Up @@ -94,6 +95,7 @@ public function testSimple() {
}

public function testFacade() {
Schema::dropIfExists('test');
Schema::create('test', function (Blueprint $table) {
$table->bigIncrements('id');
$table->timestamps();
Expand Down Expand Up @@ -175,6 +177,7 @@ public function testFacade() {
}

public function testMulti() {
Schema::dropIfExists('test');
Schema::create('test', function (Blueprint $table) {
$table->bigIncrements('id');
$table->timestamps();
Expand Down Expand Up @@ -243,6 +246,7 @@ public function testConnection() {
$table->string('name');
});

Schema::dropIfExists('test1');
DB::beginTransaction('sqlite_test');
$model = new Test1Model();
$model->id = 4;
Expand Down
6 changes: 3 additions & 3 deletions tests/ProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ public function testMake() {
$command = $application->get('make:provider');
$command->run(new ArgvInput([
'input',
'--name=test'
'--name=test1'
]), ioutputer());

$this->assertSame(true, file_exists(APP_PATH . '/Provider/TestProvider.php'));
$this->assertSame(true, file_exists(APP_PATH . '/Provider/Test1Provider.php'));

unlink(APP_PATH . '/Provider/TestProvider.php');
unlink(APP_PATH . '/Provider/Test1Provider.php');
}

public function testRoute() {
Expand Down
5 changes: 4 additions & 1 deletion tests/SessionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ public function testUserHandler() {
$config = iconfig()->getUserConfig('app');
$config['session']['handler'] = 'test';
iconfig()->setUserConfig('app', $config);
$handler = iconfig()->getUserConfig('handler');
$handler['session']['test'] = TestHandler::class;
iconfig()->setUserConfig('handler', $handler);

$session = new Session();
$sessionReflect = new \ReflectionClass($session);
Expand All @@ -78,6 +81,6 @@ public function testUserHandler() {
$handler = $property->getValue($session);
$this->assertSame(true, $handler instanceof TestHandler);

$filesystem->deleteDirectory(APP_PATH . '/Handler/Session');
$filesystem->delete(APP_PATH . '/Handler/Session/TestHandler.php');
}
}
5 changes: 2 additions & 3 deletions tests/Util/Handler/MakeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,15 @@ public function testMakeWithName() {
foreach ($this->supportTypeWithName as $type) {
$command->run(new ArgvInput([
'input',
'--name=test',
'--name=testMake',
'--type=' . $type
]), ioutputer());

$file = APP_PATH . '/Handler/' . ucfirst($type) . '/TestHandler.php';
$file = APP_PATH . '/Handler/' . ucfirst($type) . '/TestMakeHandler.php';

$this->assertSame(true, file_exists($file));

unlink($file);
rmdir(pathinfo($file, PATHINFO_DIRNAME));
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Util/Handler/Session/TestHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function read($session_id) {
return $this->data[$session_id];
}

public function destroy($session_id) {
public function destroy($session_id, $flag = SESSION_DESTROY) {
unset($this->data[$session_id]);
}

Expand Down

0 comments on commit d50382b

Please sign in to comment.