<commit_before><?php

/*
 * This file is part of the CRUDlex package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace CRUDlexTests;

use CRUDlex\CRUDServiceProvider;
use CRUDlex\CRUDEntity;
use CRUDlexTestEnv\CRUDTestDataFactory;

class CRUDEntityDefinitionTest extends \PHPUnit_Framework_TestCase {

    protected $definition;

    protected function setUp() {
        $crudServiceProvider = new CRUDServiceProvider();
        $dataFactory = new CRUDTestDataFactory();
        $crudFile = __DIR__.'/../crud.yml';
        $stringsFile = __DIR__.'/../../src/strings.yml';
        $crudServiceProvider->init($dataFactory, $crudFile, $stringsFile);
        $this->definition = $crudServiceProvider->getData('book')->getDefinition();
    }

    public function testGetFieldNames() {
        $read = $this->definition->getFieldNames();
        $expected = array(
            'id',
            'created_at',
            'updated_at',
            'version',
            'deleted_at',
            'title',
            'author',
            'pages',
            'release',
            'library'
        );
        $this->assertSame($read, $expected);
    }

    public function testGetType() {
        $fields = array('title', 'pages', 'release', 'library');
        $expected = array('text', 'int', 'date', 'reference', null);
        $read = array();
        foreach ($fields as $field) {
            $read[] = $this->definition->getType($field);
        }
        $read[] = $this->definition->getType('foo');
        $this->assertSame($read, $expected);
    }

    public function testGetPublicFieldNames() {
        $read = $this->definition->getPublicFieldNames();
        $expected = array(
            'id',
            'created_at',
            'updated_at',
            'title',
            'author',
            'pages',
            'release',
            'library'
        );
        $this->assertSame($read, $expected);
    }

}<commit_msg>testing the rest of CRUDEntityDefinition<commit_after><?php

/*
 * This file is part of the CRUDlex package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace CRUDlexTests;

use CRUDlex\CRUDServiceProvider;
use CRUDlex\CRUDEntity;
use CRUDlexTestEnv\CRUDTestDataFactory;

class CRUDEntityDefinitionTest extends \PHPUnit_Framework_TestCase {

    protected $definition;

    protected $definitionLibrary;

    protected function setUp() {
        $crudServiceProvider = new CRUDServiceProvider();
        $dataFactory = new CRUDTestDataFactory();
        $crudFile = __DIR__.'/../crud.yml';
        $stringsFile = __DIR__.'/../../src/strings.yml';
        $crudServiceProvider->init($dataFactory, $crudFile, $stringsFile);
        $this->definition = $crudServiceProvider->getData('book')->getDefinition();
        $this->definitionLibrary = $crudServiceProvider->getData('library')->getDefinition();
    }

    public function testGetFieldNames() {
        $read = $this->definition->getFieldNames();
        $expected = array(
            'id',
            'created_at',
            'updated_at',
            'version',
            'deleted_at',
            'title',
            'author',
            'pages',
            'release',
            'library'
        );
        $this->assertSame($read, $expected);
    }

    public function testGetType() {
        $fields = array('title', 'pages', 'release', 'library');
        $expected = array('text', 'int', 'date', 'reference', null);
        $read = array();
        foreach ($fields as $field) {
            $read[] = $this->definition->getType($field);
        }
        $read[] = $this->definition->getType('foo');
        $this->assertSame($read, $expected);
    }

    public function testGetPublicFieldNames() {
        $read = $this->definition->getPublicFieldNames();
        $expected = array(
            'id',
            'created_at',
            'updated_at',
            'title',
            'author',
            'pages',
            'release',
            'library'
        );
        $this->assertSame($read, $expected);
    }

    public function testIsRequired() {
        $read = $this->definition->isRequired('title');
        $this->assertTrue($read);
        $read = $this->definition->isRequired('release');
        $this->assertFalse($read);
        $read = $this->definition->isRequired('false');
        $this->assertFalse($read);
        $read = $this->definition->isRequired(null);
        $this->assertFalse($read);
    }

    public function testGetReferenceTable() {
        $read = $this->definition->getReferenceTable('library');
        $expected = 'library';
        $this->assertSame($read, $expected);
        $read = $this->definition->getReferenceTable('title');
        $this->assertNull($read);
        $read = $this->definition->getReferenceTable('foo');
        $this->assertNull($read);
        $read = $this->definition->getReferenceTable(null);
        $this->assertNull($read);
    }

    public function testGetReferenceNameField() {
        $read = $this->definition->getReferenceNameField('library');
        $expected = 'name';
        $this->assertSame($read, $expected);
        $read = $this->definition->getReferenceNameField('title');
        $this->assertNull($read);
        $read = $this->definition->getReferenceNameField('foo');
        $this->assertNull($read);
        $read = $this->definition->getReferenceNameField(null);
        $this->assertNull($read);
    }

    public function testGetReferenceEntity() {
        $read = $this->definition->getReferenceEntity('library');
        $expected = 'library';
        $this->assertSame($read, $expected);
        $read = $this->definition->getReferenceEntity('title');
        $this->assertNull($read);
        $read = $this->definition->getReferenceEntity('foo');
        $this->assertNull($read);
        $read = $this->definition->getReferenceEntity(null);
        $this->assertNull($read);
    }

    public function testIsUnique() {
        $read = $this->definitionLibrary->isUnique('name');
        $this->assertTrue($read);
        $read = $this->definition->isUnique('release');
        $this->assertFalse($read);
        $read = $this->definition->isUnique('false');
        $this->assertFalse($read);
        $read = $this->definition->isUnique(null);
        $this->assertFalse($read);
    }

    public function testGetFieldLabel() {
        $read = $this->definition->getFieldLabel('library');
        $expected = 'Library';
        $this->assertSame($read, $expected);
        $read = $this->definition->getFieldLabel('id');
        $expected = 'Id';
        $this->assertSame($read, $expected);
        $read = $this->definition->getFieldLabel('foo');
        $expected = 'foo';
        $this->assertSame($read, $expected);
        $read = $this->definition->getFieldLabel(null);
        $this->assertNull($read);
    }

    public function testGetTable() {
        $read = $this->definition->getTable();
        $expected = 'book';
        $this->assertSame($read, $expected);
    }

    public function testGetLabel() {
        $read = $this->definition->getLabel();
        $expected = 'Book';
        $this->assertSame($read, $expected);
    }

    public function testAddAndGetParent() {
        $this->definition->addParent('foo', 'bar');
        $read = $this->definition->getParents();
        $expected = array(
            array('foo', 'bar')
        );
        $this->assertSame($read, $expected);
    }

}
{'fraction_non_alphanumeric': 0.15940709920686516, 'fraction_numerical': 0.0, 'mean_word_length': 2.477396021699819, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 125, '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': '4145605', 'n_tokens_mistral': 2137, 'n_tokens_neox': 2130, 'n_words': 397}