CodeIgniter Forums
ControllerTester double execution - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: ControllerTester double execution (/showthread.php?tid=78227)



ControllerTester double execution - David Schmucker - 12-17-2020

Hello,

if i execute the Code below, then the second execution always execute the created request of the first execution. Hence the second body are ignored.

Code:
$body = json_encode(['foo' => 'bar']);

$results = $this->withBody($body)
                ->controller(\App\Controllers\ForumController::class)
                ->execute('showCategories');


$body2 = json_encode(['bar' => 'foo']);

$results2 = $this->withBody($body2)
                ->controller(\App\Controllers\ForumController::class)
                ->execute('showCategories');

A workaround is:
Code:
$results2 = $this->withRequest(null)
                ->withBody($body2)
                ->controller(\App\Controllers\ForumController::class)
                ->execute('showCategories');
 to reset the Request. But i think that isn't meant to be.