<?php

namespace Dipper\Foundation\Core;

use Faker\Generator;
use Laravel\Lumen\Testing\DatabaseMigrations;
use Laravel\Lumen\Testing\DatabaseTransactions;
use Laravel\Lumen\Testing\TestCase as BaseTestCase;

abstract class TestCase extends BaseTestCase
{
    use DatabaseMigrations;
    use DatabaseTransactions;

    protected $faker;
    
    /**
     * Creates the application.
     *
     * @return \Laravel\Lumen\Application
     */
    public function createApplication()
    {
        foreach (array(__DIR__ . '/../../../../', __DIR__ . '/../../../../../') as $basePath) {
            if (file_exists($basePath.'/bootstrap/app.php')) {
                break;
            }
        }

        $app = require $basePath.'/bootstrap/app.php';

        $this->faker = $app->make(Generator::class);
        
        return $app;
    }

    /**
     * Setup the test environment.
     *
     * @return void
     */
    public function setUp()
    {
        parent::setUp();
        $this->artisan('db:seed');
    }
}
