vargvinter - 9 months ago

Hello,

Question to the testing masters. @fryiee

How to perform deletion in the test? I am doing:

class FoobarModuleTest extends \TestCase
{
    use DatabaseTransactions;

    public function testFeature()
    {
        auth()->loginUsingId(1);

        $object = factory(ObjectModel::class)->create();

        $this->assertDatabaseHas('foobar_objects', [
            'id' => $object->id
        ]);

        $this->post('/admin/foobar/objects', [
            'action' => 'delete',
            'id[]' => [$object->id]
        ]);

        $this->assertDatabaseMissing('foobar_objects', [
            'id' => $object->id
        ]);
    }
}

but it throws

LogicException: Unable to register extension "nochso\HtmlCompressTwig\Extension" as it is already registered.

C:\xampp\htdocs\pyrocms\vendor\twig\twig\lib\Twig\ExtensionSet.php:160
C:\xampp\htdocs\pyrocms\vendor\twig\twig\lib\Twig\Environment.php:668
C:\xampp\htdocs\pyrocms\vendor\anomaly\streams-platform\src\StreamsServiceProvider.php:258
C:\xampp\htdocs\pyrocms\vendor\laravel\framework\src\Illuminate\Events\Dispatcher.php:349
C:\xampp\htdocs\pyrocms\vendor\laravel\framework\src\Illuminate\Events\Dispatcher.php:200
C:\xampp\htdocs\pyrocms\vendor\laravel\framework\src\Illuminate\Events\Dispatcher.php:173
C:\xampp\htdocs\pyrocms\vendor\anomaly\streams-platform\src\View\Listener\LoadTemplateData.php:70
C:\xampp\htdocs\pyrocms\vendor\laravel\framework\src\Illuminate\Events\Dispatcher.php:368
C:\xampp\htdocs\pyrocms\vendor\laravel\framework\src\Illuminate\Events\Dispatcher.php:200
C:\xampp\htdocs\pyrocms\vendor\laravel\framework\src\Illuminate\Events\Dispatcher.php:173
C:\xampp\htdocs\pyrocms\vendor\anomaly\streams-platform\src\View\ViewComposer.php:158
C:\xampp\htdocs\pyrocms\vendor\laravel\framework\src\Illuminate\View\Concerns\ManagesEvents.php:125
C:\xampp\htdocs\pyrocms\vendor\laravel\framework\src\Illuminate\View\Concerns\ManagesEvents.php:164
C:\xampp\htdocs\pyrocms\vendor\laravel\framework\src\Illuminate\Events\Dispatcher.php:347
C:\xampp\htdocs\pyrocms\vendor\laravel\framework\src\Illuminate\Events\Dispatcher.php:200
C:\xampp\htdocs\pyrocms\vendor\laravel\framework\src\Illuminate\View\Concerns\ManagesEvents.php:179
C:\xampp\htdocs\pyrocms\vendor\laravel\framework\src\Illuminate\View\View.php:118
C:\xampp\htdocs\pyrocms\vendor\laravel\framework\src\Illuminate\View\View.php:85
C:\xampp\htdocs\pyrocms\vendor\laravel\framework\src\Illuminate\Http\Response.php:42
C:\xampp\htdocs\pyrocms\vendor\symfony\http-foundation\Response.php:200
C:\xampp\htdocs\pyrocms\vendor\laravel\framework\src\Illuminate\Routing\ResponseFactory.php:55
C:\xampp\htdocs\pyrocms\vendor\laravel\framework\src\Illuminate\Routing\ResponseFactory.php:69
C:\xampp\htdocs\pyrocms\vendor\anomaly\streams-platform\src\Exception\ExceptionHandler.php:73
C:\xampp\htdocs\pyrocms\vendor\laravel\framework\src\Illuminate\Foundation\Exceptions\Handler.php:295
C:\xampp\htdocs\pyrocms\vendor\laravel\framework\src\Illuminate\Foundation\Exceptions\Handler.php:187
C:\xampp\htdocs\pyrocms\vendor\anomaly\streams-platform\src\Exception\ExceptionHandler.php:51
C:\xampp\htdocs\pyrocms\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php:326
C:\xampp\htdocs\pyrocms\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php:120
C:\xampp\htdocs\pyrocms\vendor\laravel\framework\src\Illuminate\Foundation\Testing\Concerns\MakesHttpRequests.php:345
C:\xampp\htdocs\pyrocms\vendor\laravel\framework\src\Illuminate\Foundation\Testing\Concerns\MakesHttpRequests.php:195
C:\xampp\htdocs\pyrocms\addons\default\acme\foobar-module\tests\Feature\FoobarModuleTest.php:18

O_o