Skip to content

Commit

Permalink
test: fix tests (wip)
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed May 5, 2022
1 parent 24f5eb5 commit 0fce2b8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
27 changes: 18 additions & 9 deletions tests/system/RESTful/ResourceControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ protected function setUp(): void
{
parent::setUp();

$this->resetServices();
$this->resetServices(true);
$this->resetFactories();
}

private function createCodeigniter(): void
Expand Down Expand Up @@ -92,7 +93,8 @@ public function testResourceGet()
$this->codeigniter->useSafeOutput(true)->run($this->routes);
$output = ob_get_clean();

$this->assertStringContainsString(lang('RESTful.notImplemented', ['index']), $output);
$error = json_decode($output)->messages->error;
$this->assertStringContainsString(lang('RESTful.notImplemented', ['index']), $error);
}

public function testResourceGetNew()
Expand All @@ -113,7 +115,8 @@ public function testResourceGetNew()
$this->codeigniter->useSafeOutput(true)->run($this->routes);
$output = ob_get_clean();

$this->assertStringContainsString(lang('RESTful.notImplemented', ['new']), $output);
$error = json_decode($output)->messages->error;
$this->assertStringContainsString(lang('RESTful.notImplemented', ['new']), $error);
}

public function testResourceGetEdit()
Expand All @@ -135,7 +138,8 @@ public function testResourceGetEdit()
$this->codeigniter->useSafeOutput(true)->run($this->routes);
$output = ob_get_clean();

$this->assertStringContainsString(lang('RESTful.notImplemented', ['edit']), $output);
$error = json_decode($output)->messages->error;
$this->assertStringContainsString(lang('RESTful.notImplemented', ['edit']), $error);
}

public function testResourceGetOne()
Expand All @@ -156,7 +160,8 @@ public function testResourceGetOne()
$this->codeigniter->useSafeOutput(true)->run($this->routes);
$output = ob_get_clean();

$this->assertStringContainsString(lang('RESTful.notImplemented', ['show']), $output);
$error = json_decode($output)->messages->error;
$this->assertStringContainsString(lang('RESTful.notImplemented', ['show']), $error);
}

public function testResourcePost()
Expand All @@ -176,7 +181,8 @@ public function testResourcePost()
$this->codeigniter->useSafeOutput(true)->run($this->routes);
$output = ob_get_clean();

$this->assertStringContainsString(lang('RESTful.notImplemented', ['create']), $output);
$error = json_decode($output)->messages->error;
$this->assertStringContainsString(lang('RESTful.notImplemented', ['create']), $error);
}

public function testResourcePatch()
Expand All @@ -197,7 +203,8 @@ public function testResourcePatch()
$this->codeigniter->useSafeOutput(true)->run($this->routes);
$output = ob_get_clean();

$this->assertStringContainsString(lang('RESTful.notImplemented', ['patch']), $output);
$error = json_decode($output)->messages->error;
$this->assertStringContainsString(lang('RESTful.notImplemented', ['update']), $error);
}

public function testResourcePut()
Expand All @@ -218,7 +225,8 @@ public function testResourcePut()
$this->codeigniter->useSafeOutput(true)->run($this->routes);
$output = ob_get_clean();

$this->assertStringContainsString(lang('RESTful.notImplemented', ['put']), $output);
$error = json_decode($output)->messages->error;
$this->assertStringContainsString(lang('RESTful.notImplemented', ['update']), $error);
}

public function testResourceDelete()
Expand All @@ -239,7 +247,8 @@ public function testResourceDelete()
$this->codeigniter->useSafeOutput(true)->run($this->routes);
$output = ob_get_clean();

$this->assertStringContainsString(lang('RESTful.notImplemented', ['delete']), $output);
$error = json_decode($output)->messages->error;
$this->assertStringContainsString(lang('RESTful.notImplemented', ['delete']), $error);
}

public function testModel()
Expand Down
3 changes: 2 additions & 1 deletion tests/system/RESTful/ResourcePresenterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ protected function setUp(): void
{
parent::setUp();

$this->resetServices();
$this->resetServices(true);
$this->resetFactories();
}

private function createCodeigniter(): void
Expand Down
4 changes: 3 additions & 1 deletion tests/system/Router/RouteCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ protected function setUp(): void
{
parent::setUp();

$this->resetServices();
$this->resetServices(true);
$this->resetFactories();
}

protected function getCollector(array $config = [], array $files = [], $moduleConfig = null)
Expand Down Expand Up @@ -1661,6 +1662,7 @@ public function testAutoRoutesControllerNameReturnsFQCN($namespace)
*/
public function testRoutesControllerNameReturnsFQCN($namespace)
{
Services::request()->setMethod('get');
$routes = $this->getCollector();
$routes->setAutoRoute(false);
$routes->setDefaultNamespace($namespace);
Expand Down

0 comments on commit 0fce2b8

Please sign in to comment.