<commit_before><?php namespace Vinelab\NeoEloquent\Tests;

use Vinelab\NeoEloquent\Connection;
use PHPUnit_Framework_TestCase as PHPUnit;

class TestCase extends PHPUnit {

    public function __construct()
    {
        parent::__construct();

        // load custom configuration file
        $this->dbConfig = require 'config/database.php';
    }

    public static function setUpBeforeClass()
    {
        date_default_timezone_set('Asia/Beirut');
    }

    protected function getConnectionWithConfig($config = null)
    {
        $connection = is_null($config) ? $this->dbConfig['connections']['default'] :
                                         $this->dbConfig['connections'][$config];

        return new Connection($connection);
    }

}<commit_msg>add a flush to TestCase<commit_after><?php namespace Vinelab\NeoEloquent\Tests;

use Mockery as M;
use Vinelab\NeoEloquent\Connection;
use Vinelab\NeoEloquent\Eloquent\Model;
use PHPUnit_Framework_TestCase as PHPUnit;

class Stub extends Model {

}

class TestCase extends PHPUnit {

    public function __construct()
    {
        parent::__construct();

        // load custom configuration file
        $this->dbConfig = require 'config/database.php';
    }

    public function setUp()
    {
        parent::setUp();

        $resolver = M::mock('Illuminate\Database\ConnectionResolverInterface');
        $resolver->shouldReceive('connection')->andReturn($this->getConnectionWithConfig('default'));

        Stub::setConnectionResolver($resolver);
    }

    public function tearDown()
    {
        // everything should be clean before every test
        $this->flushDb();

        parent::tearDown();
    }

    public static function setUpBeforeClass()
    {
        date_default_timezone_set('Asia/Beirut');
    }

    /**
     * Get the connection with a given or the default configuration.
     *
     * @param  string $config As specified in config/database.php
     * @return \Vinelab\NeoEloquent\Connection
     */
    protected function getConnectionWithConfig($config = null)
    {
        $connection = is_null($config) ? $this->dbConfig['connections']['default'] :
                                         $this->dbConfig['connections'][$config];

        return new Connection($connection);
    }

    /**
     * Flush all database records.
     *
     * @return void
     */
    protected function flushDb()
    {
        $connection = (new Stub)->getConnection();
        $client = $connection->getClient();
        // Remove all relationships and related nodes
        $query = new \Everyman\Neo4j\Cypher\Query($client, 'MATCH (n)-[r]-(c) DELETE n,r,c');
        $query->getResultSet();
        // Remove singular nodes with no relations
        $query = new \Everyman\Neo4j\Cypher\Query($client, 'MATCH (n) DELETE n');
        $query->getResultSet();
    }
}
{'fraction_non_alphanumeric': 0.11893033075299085, 'fraction_numerical': 0.0007037297677691766, 'mean_word_length': 2.663659793814433, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6300243', 'n_tokens_mistral': 812, 'n_tokens_neox': 788, 'n_words': 175}