<commit_before><?php

namespace Laravolt\Auth\Tests;

use Illuminate\Database\Schema\Blueprint;
use Laravolt\Auth\Tests\Dummy\User;
use Orchestra\Database\ConsoleServiceProvider;
use Orchestra\Testbench\BrowserKit\TestCase as BaseTestCase;

abstract class TestCase extends BaseTestCase
{
    protected function getDatabasePath()
    {
        //return __DIR__.'/database/auth.sqlite';
        return ':memory:';
    }

    protected function setUp()
    {
        parent::setUp();
        $this->setUpDatabase();
    }

    protected function tearDown()
    {
        parent::tearDown();
    }

    protected function getPackageProviders($app)
    {
        return [
            \Laravolt\Auth\ServiceProvider::class,
            'Anhskohbo\NoCaptcha\NoCaptchaServiceProvider',
            ConsoleServiceProvider::class,
        ];
    }

    protected function getEnvironmentSetUp($app)
    {
        $app['config']->set('database.default', 'sqlite');
        $app['config']->set('database.connections.sqlite', [
            'driver'   => 'sqlite',
            'database' => $this->getDatabasePath(),
            'prefix'   => '',
        ]);

        $app['config']->set('auth.providers.users.model', User::class);
        $app['config']->set('laravolt.auth.redirect.after_login', '/login-success');
        $app['config']->set('laravolt.auth.redirect.after_reset_password', '/reset-password-success');
        $app['config']->set('session.expire_on_close', false);

        //$app->make('Illuminate\Contracts\Http\Kernel')->pushMiddleware(\Illuminate\Session\Middleware\StartSession::class);

    }

    protected function setUpDatabase()
    {
        //if (!file_exists($file = $this->getDatabasePath())) {
        //    touch($file);
        //} else {
        //    $this->cleanDatabase();
        //}

        $this->createUserTable();

//        $this->loadLaravelMigrations();

        $this->loadMigrationsFrom(realpath(__DIR__.'/../database/migrations'));

        $this->beforeApplicationDestroyed(function () {
            $this->cleanDatabase();
        });

        User::create(['name' => 'Andi', 'email' => '<EMAIL>', 'password' => bcrypt('<PASSWORD>')]);
    }

    protected function cleanDatabase()
    {
        //file_put_contents($this->getDatabasePath(), null);
    }

    protected function createUserTable()
    {
        $this->app['db']->connection()->getSchemaBuilder()->create('users', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('email')->unique();
            $table->string('password');
            $table->string('status')->default('ACTIVE');<commit_msg>clean up test<commit_after><?php

namespace Laravolt\Auth\Tests;

use Illuminate\Database\Schema\Blueprint;
use Laravolt\Auth\Tests\Dummy\User;
use Orchestra\Database\ConsoleServiceProvider;
use Orchestra\Testbench\BrowserKit\TestCase as BaseTestCase;

abstract class TestCase extends BaseTestCase
{
    protected function getDatabasePath()
    {
        return ':memory:';
    }

    protected function setUp()
    {
        parent::setUp();
        $this->setUpDatabase();
    }

    protected function tearDown()
    {
        parent::tearDown();
    }

    protected function getPackageProviders($app)
    {
        return [
            \Laravolt\Auth\ServiceProvider::class,
            'Anhskohbo\NoCaptcha\NoCaptchaServiceProvider',
            ConsoleServiceProvider::class,
        ];
    }

    protected function getEnvironmentSetUp($app)
    {
        $app['config']->set('database.default', 'sqlite');
        $app['config']->set('database.connections.sqlite', [
            'driver'   => 'sqlite',
            'database' => $this->getDatabasePath(),
            'prefix'   => '',
        ]);

        $app['config']->set('auth.providers.users.model', User::class);
        $app['config']->set('laravolt.auth.redirect.after_login', '/login-success');
        $app['config']->set('laravolt.auth.redirect.after_reset_password', '/reset-password-success');
        $app['config']->set('session.expire_on_close', false);
        //$app->make('Illuminate\Contracts\Http\Kernel')->pushMiddleware(\Illuminate\Session\Middleware\StartSession::class);

    }

    protected function setUpDatabase()
    {
        $this->createUserTable();

        $this->loadMigrationsFrom(realpath(__DIR__.'/../database/migrations'));

        User::create(['name' => 'Andi', 'email' => '<EMAIL>', 'password' => bcrypt('<PASSWORD>')]);
    }

    protected function createUserTable()
    {
        $this->app['db']->connection()->getSchemaBuilder()->create('users', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('email')->unique();
            $table->string('password');
{'fraction_non_alphanumeric': 0.17008919311346193, 'fraction_numerical': 0.0, 'mean_word_length': 2.8058405682715075, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 69, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5960177', 'n_tokens_mistral': 1376, 'n_tokens_neox': 1367, 'n_words': 180}