<commit_before><?php

namespace Contrask\Test\Component\Project\Manager;

use Contrask\Component\Project\Model\Project;
use Contrask\Component\Project\Manager\ProjectManager;
use Contrask\Test\Component\Project\EntityManagerBuilder;
use Doctrine\ORM\EntityManager;

/**
 * @author <NAME> <<EMAIL>>
 */
class ProjectManagerTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @var EntityManager
     */
    protected $em;
    
    public function setUp()
    {
        $builder = new EntityManagerBuilder();
        $this->em = $builder->createEntityManager(
            array(
                sprintf("%s/../../../../../../src/Contrask/Component/Project/Resources/config/doctrine", __DIR__),
            ),
            array(
                'Contrask\Component\Project\Model\Project',
            )
        );
    }

    /**
     * @covers \Contrask\Component\Project\Manager\ProjectManager::__construct
     */
    public function testConstructor()
    {
        $manager = new ProjectManager($this->em);

        $this->assertAttributeEquals($this->em, 'em', $manager);
        $this->assertAttributeEquals($this->em->getRepository('Contrask\Component\Project\Model\Project'), 'repository', $manager);
    }

    /**
     * @covers \Contrask\Component\Project\Manager\ProjectManager::pick
     */
    public function testPickWithStringCriteria()
    {
        /*Fixtures*/
        $project = new Project();
        $this->em->persist($project);

        $this->em->flush();

        /*Tests*/
        $projectManager = new ProjectManager($this->em);
        $this->assertAttributeEquals(1, 'id', $projectManager->pick('1'));
    }

    /**
     * @covers \Contrask\Component\Project\Manager\ProjectManager::pick
     */
    public function testPickWithArrayCriteria()
    {
        /*Fixtures*/
        $project = new Project();
        $this->em->persist($project);

        $this->em->flush();

        /*Tests*/
        $projectManager = new ProjectManager($this->em);
        $this->assertAttributeEquals(1, 'id', $projectManager->pick(array('id' => '1')));
    }

    /**
     * @covers \Contrask\Component\Project\Manager\ProjectManager::collect
     */
    public function testCollectWithNullCriteria()
    {
        /*Fixtures*/
        $project = new Project();
        $this->em->persist($project);

        $project1 = new Project();
        $this->em->persist($project1);

        $this->em->flush();

        /*Tests*/
        $projectManager = new ProjectManager($this->em);
        $this->assertEquals(2, count($projectManager->collect()));
    }

    /**
     * @covers \Contrask\Component\Project\Manager\ProjectManager::collect
     */
    public function testCollectWithStringCriteria()
    {
        /*Fixtures*/
        $project = new Project();
        $this->em->persist($project);

        $project1 = new Project();
        $this->em->persist($project1);

        $this->em->flush();

        /*Tests*/
        $projectManager = new ProjectManager($this->em);
        $this->assertEquals(1, count($projectManager->collect('1')));
        $this->assertEquals(0, count($projectManager->collect('3')));
    }

    /**
     * @covers \Contrask\Component\Project\Manager\ProjectManager::collect
     */
    public function testCollectWithArrayCriteria()
    {
        /*Fixtures*/
        $project = new Project();
        $this->em->persist($project);

        $project1 = new Project();
        $this->em->persist($project1);
<commit_msg>Removed test case when $criteria is string<commit_after><?php

namespace Contrask\Test\Component\Project\Manager;

use Contrask\Component\Project\Model\Project;
use Contrask\Component\Project\Manager\ProjectManager;
use Contrask\Test\Component\Project\EntityManagerBuilder;
use Doctrine\ORM\EntityManager;

/**
 * @author <NAME> <<EMAIL>>
 */
class ProjectManagerTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @var EntityManager
     */
    protected $em;
    
    public function setUp()
    {
        $builder = new EntityManagerBuilder();
        $this->em = $builder->createEntityManager(
            array(
                sprintf("%s/../../../../../../src/Contrask/Component/Project/Resources/config/doctrine", __DIR__),
            ),
            array(
                'Contrask\Component\Project\Model\Project',
            )
        );
    }

    /**
     * @covers \Contrask\Component\Project\Manager\ProjectManager::__construct
     */
    public function testConstructor()
    {
        $manager = new ProjectManager($this->em);

        $this->assertAttributeEquals($this->em, 'em', $manager);
        $this->assertAttributeEquals($this->em->getRepository('Contrask\Component\Project\Model\Project'), 'repository', $manager);
    }

    /**
     * @covers \Contrask\Component\Project\Manager\ProjectManager::pick
     */
    public function testPickWithStringCriteria()
    {
        /*Fixtures*/
        $project = new Project();
        $this->em->persist($project);

        $this->em->flush();

        /*Tests*/
        $projectManager = new ProjectManager($this->em);
        $this->assertAttributeEquals(1, 'id', $projectManager->pick('1'));
    }

    /**
     * @covers \Contrask\Component\Project\Manager\ProjectManager::pick
     */
    public function testPickWithArrayCriteria()
    {
        /*Fixtures*/
        $project = new Project();
        $this->em->persist($project);

        $this->em->flush();

        /*Tests*/
        $projectManager = new ProjectManager($this->em);
        $this->assertAttributeEquals(1, 'id', $projectManager->pick(array('id' => '1')));
    }

    /**
     * @covers \Contrask\Component\Project\Manager\ProjectManager::collect
     */
    public function testCollectWithNullCriteria()
    {
        /*Fixtures*/
        $project = new Project();
        $this->em->persist($project);

        $project1 = new Project();
        $this->em->persist($project1);

        $this->em->flush();

        /*Tests*/
        $projectManager = new ProjectManager($this->em);
        $this->assertEquals(2, count($projectManager->collect()));
    }

    /**
     * @covers \Contrask\Component\Project\Manager\ProjectManager::collect
     */
    public function testCollectWithArrayCriteria()
    {
        /*Fixtures*/
        $project = new Project();
        $this->em->persist($project);

        $project1 = new Project();
        $this->em->persist($project1);

{'fraction_non_alphanumeric': 0.16119449656035023, 'fraction_numerical': 0.00375234521575985, 'mean_word_length': 2.4503775620280477, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 92, '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': '679541', 'n_tokens_mistral': 1821, 'n_tokens_neox': 1784, 'n_words': 271}