<commit_before><?php
/**
 * This file is part of the Everon framework.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Everon\Test\DataMapper;

use Everon\DataMapper;
use Everon\Interfaces;
use Everon\Helper;

class SchemaTest extends \Everon\TestCase
{
    use Helper\Arrays;
    
    public function testConstructor()
    {
        $ConnectionManager = $this->getMock('\Everon\DataMapper\Interfaces\ConnectionManager');
        $Reader = $this->getMock('\Everon\DataMapper\Interfaces\Schema\Reader');
        
        $Manager = new \Everon\DataMapper\Schema($Reader, $ConnectionManager);
        $this->assertInstanceOf('\Everon\DataMapper\Interfaces\Schema', $Manager);
    }

    /**
     * @dataProvider dataProvider
     */
    public function testGetConnectionManagerShouldReturnInstanceOfConnectionManager(DataMapper\Interfaces\Schema $Schema)
    {
        $ConnectionManager = $Schema->getConnectionManager();
        $this->assertInstanceOf('\Everon\DataMapper\Interfaces\ConnectionManager', $ConnectionManager);
    }
    
    /**
     * @dataProvider dataProvider
     */
    public function testGetPdoAdapterShouldReturnPdoAdapter(DataMapper\Interfaces\Schema $Schema)
    {
        $PdoAdapter = $Schema->getPdoAdapterByName('schema');
        $this->assertInstanceOf('\Everon\Interfaces\PdoAdapter', $PdoAdapter);
    }
    
    /**
     * @dataProvider dataProvider
     */
    public function testGetNameShouldReturnNameOfSchemaReader(DataMapper\Interfaces\Schema $Schema)
    {
        $name = $Schema->getName();
        $this->assertEquals('everon_test', $name);
    }
    
    /**
     * @dataProvider dataProvider
     */
    public function testGetTablesShouldReturnArray(DataMapper\Interfaces\Schema $Schema)
    {
        $tables = $Schema->getTables();
        $this->assertInternalType('array', $tables);
    }

    /**
     * @dataProvider dataProvider
     */
    public function testSetTablesShouldSetTables(DataMapper\Interfaces\Schema $Schema)
    {
        $Schema->setTables([]);
        $this->assertInternalType('array', $Schema->getTables());
    }

    /**
     * @dataProvider dataProvider
     */
    public function testGetTableShouldReturnSchemaTableInstance(DataMapper\Interfaces\Schema $Schema)
    {
        $Table = $Schema->getTable('test_user');
        $this->assertInstanceOf('\Everon\DataMapper\Interfaces\Schema\Table', $Table);
    }
    
    public function dataProvider()
    {
        $SchemaReaderMock = $this->getMock('\Everon\DataMapper\Interfaces\Schema\Reader');
        
        $tables = $this->arrayArrangeByKey('TABLE_NAME', $this->getFixtureData()['db_tables.php']);
        $columns = $this->arrayArrangeByKey('TABLE_NAME', $this->getFixtureData()['db_columns.php']);
        $constraints = $this->arrayArrangeByKey('TABLE_NAME', $this->getFixtureData()['db_constraints.php']);
        $foreign_keys = $this->arrayArrangeByKey('TABLE_NAME', $this->getFixtureData()['db_foreign_keys.php']);

        $SchemaReaderMock->expects($this->once())
            ->method('getTableList')
            ->will($this->returnValue($tables));
        
        $SchemaReaderMock->expects($this->once())
            ->method('getColumnList')
            ->will($this->returnValue($columns));
        
        $SchemaReaderMock->expects($this->once())
            ->method('getConstraintList')
            ->will($this->returnValue($constraints));
        
        $SchemaReaderMock->expects($this->once())
            ->method('getForeignKeyList')
            ->will($this->returnValue($foreign_keys));

        $SchemaReaderMock->expects($this->once())
            ->method('getName')
            ->will($this->returnValue('everon_test'));

        //$C = $this->getMock('\Everon\DataMapper\Interfaces\ConnectionManager'); //why the fuck does it return null
        $DatabaseConfig = $this->getFactory()->getDependencyContainer()->resolve('ConfigManager')->getConfigByName('database');
        $ConnectionManager = $this->getFactory()->buildConnectionManager($DatabaseConfig);
        
        $Schema = $this->getFactory()->buildSchema($SchemaReaderMock, $ConnectionManager);
        
        return [
            [$Schema]
        ];
    }
}<commit_msg>updated Schema test<commit_after><?php
/**
 * This file is part of the Everon framework.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Everon\Test\DataMapper;

use Everon\DataMapper;
use Everon\Interfaces;
use Everon\Helper;

class SchemaTest extends \Everon\TestCase
{
    use Helper\Arrays;
    
    public function testConstructor()
    {
        $ConnectionManager = $this->getMock('\Everon\DataMapper\Interfaces\ConnectionManager');
        $Reader = $this->getMock('\Everon\DataMapper\Interfaces\Schema\Reader');
        
        $Manager = new \Everon\DataMapper\Schema($Reader, $ConnectionManager);
        $this->assertInstanceOf('\Everon\DataMapper\Interfaces\Schema', $Manager);
    }

    /**
     * @dataProvider dataProvider
     */
    public function testGetConnectionManagerShouldReturnInstanceOfConnectionManager(DataMapper\Interfaces\Schema $Schema)
    {
        $ConnectionManager = $Schema->getConnectionManager();
        $this->assertInstanceOf('\Everon\DataMapper\Interfaces\ConnectionManager', $ConnectionManager);
    }
    
    /**
     * @dataProvider dataProvider
     */
    public function testGetPdoAdapterShouldReturnPdoAdapter(DataMapper\Interfaces\Schema $Schema)
    {
        $PdoAdapter = $Schema->getPdoAdapterByName('schema');
        $this->assertInstanceOf('\Everon\Interfaces\PdoAdapter', $PdoAdapter);
    }
    
    /**
     * @dataProvider dataProvider
     */
    public function testGetNameShouldReturnNameOfSchemaReader(DataMapper\Interfaces\Schema $Schema)
    {
        $name = $Schema->getName();
        $this->assertEquals('everon_test', $name);
    }
    
    /**
     * @dataProvider dataProvider
     */
    public function testGetTablesShouldReturnArray(DataMapper\Interfaces\Schema $Schema)
    {
        $tables = $Schema->getTables();
        $this->assertInternalType('array', $tables);
    }

    /**
     * @dataProvider dataProvider
     */
    public function testSetTablesShouldSetTables(DataMapper\Interfaces\Schema $Schema)
    {
        $Schema->setTables([]);
        $this->assertInternalType('array', $Schema->getTables());
    }

    /**
     * @dataProvider dataProvider
     */
    public function testGetTableShouldReturnSchemaTableInstance(DataMapper\Interfaces\Schema $Schema)
    {
        $Table = $Schema->getTable('test_user');
        $this->assertInstanceOf('\Everon\DataMapper\Interfaces\Schema\Table', $Table);
    }
    
    public function dataProvider()
    {
        $SchemaReaderMock = $this->getMock('\Everon\DataMapper\Interfaces\Schema\Reader');
        
        $tables = $this->arrayArrangeByKey('TABLE_NAME', $this->getFixtureData()['db_tables.php']);
        $columns = $this->arrayArrangeByKey('TABLE_NAME', $this->getFixtureData()['db_columns.php']);
        $constraints = $this->arrayArrangeByKey('TABLE_NAME', $this->getFixtureData()['db_constraints.php']);
        $foreign_keys = $this->arrayArrangeByKey('TABLE_NAME', $this->getFixtureData()['db_foreign_keys.php']);

        $SchemaReaderMock->expects($this->once())
            ->method('getTableList')
            ->will($this->returnValue($tables));
        
        $SchemaReaderMock->expects($this->once())
            ->method('getColumnList')
            ->will($this->returnValue($columns));
        
        $SchemaReaderMock->expects($this->once())
            ->method('getConstraintList')
            ->will($this->returnValue($constraints));
        
        $SchemaReaderMock->expects($this->once())
            ->method('getForeignKeyList')
            ->will($this->returnValue($foreign_keys));

        $SchemaReaderMock->expects($this->once())
            ->method('getName')
            ->will($this->returnValue('everon_test'));
        
        $Pdo = new \Everon\Test\MyPdo();
        $FactoryMock = $this->getMock('\Everon\Interfaces\Factory');
        $FactoryMock->expects($this->once())
            ->method('buildPdo')
            ->will($this->returnValue($Pdo));

        $PdoAdapterMock = $this->getMock('\Everon\Interfaces\PdoAdapter');
        $FactoryMock->expects($this->once())
            ->method('buildPdoAdapter')
            ->will($this->returnValue($PdoAdapterMock));

        $SchemaTableMock = $this->getMock('\Everon\DataMapper\Interfaces\Schema\Table');
        $FactoryMock->expects($this->exactly(3))
            ->method('buildSchemaTable')
            ->will($this->returnValue($SchemaTableMock));


        //$C = $this->getMock('\Everon\DataMapper\Interfaces\ConnectionManager'); //why the fuck does it return null
        $DatabaseConfig = $this->getFactory()->getDependencyContainer()->resolve('ConfigManager')->getConfigByName('database');
        $ConnectionManager = $this->getFactory()->buildConnectionManager($DatabaseConfig);
        
        $Schema = $this->getFactory()->buildSchema($SchemaReaderMock, $ConnectionManager);
        $Schema->setFactory($FactoryMock);
        
        return [
            [$Schema]
        ];
    }
}
{'fraction_non_alphanumeric': 0.14783717717079392, 'fraction_numerical': 0.00010628122010840685, 'mean_word_length': 3.100217864923747, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 146, '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': 2, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5990188', 'n_tokens_mistral': 2614, 'n_tokens_neox': 2592, 'n_words': 355}