<?php

namespace Test\Routes\Owner\{{ module }};

use App\DBRealTestSupport\TableCreation;
use App\DBRealTestSupport\TransactionSupported\TS{{ module }}Mother;
use App\DBRealTestSupport\TransactionSupported\Session\TSAdminSessionGenerator;
use App\DBRealTestSupport\TransactionSupported\Session\TSHistoryTableMother;
use App\Http\History\HistoryTables;
use Test\TestCase;
use Test\TransactionTrait;

class {{ module }}IndexControllerTest extends TestCase
{
    use TransactionTrait;

    private static $session;
    private static $token;
    private static $admin;

    public function init()
    {
        $this->clear();
        list(self::$session, self::$token, self::$admin) = TSAdminSessionGenerator::createAll();
        TSHistoryTableMother::insert(HistoryTables::{{ const }});
    }

    public function clear()
    {
        TSHistoryTableMother::clear();
        TableCreation::clearTables(
{{ clear }}
        );
    }

    public function testIndex()
    {
        $this->init();
        $model = TS{{ module }}Mother::pushRandom();

        $this->get('owner/{{ route }}/' . $model->id()->value(), self::$token);
        $response = $this->decoded();

        $data = $response->data[0];
{{ asserts }}
    }
}
