<commit_before><?php
namespace GitPrettyStats;

use Mockery as m;
use Carbon\Carbon;

/**
 * @covers GitPrettyStats\Repository
 */
class RepositoryTest extends \PHPUnit_Framework_TestCase
{
    public $repository;
    public $client;
    public $gitter;

    public $commits = array(
        array('Author 1', '<EMAIL>', '2013-03-01 14:55:47'),
        array('Author 1', '<EMAIL>', '2013-03-02 12:13:54'),
        array('Author 2', '<EMAIL>', '2013-03-02 14:55:47'),
        array('Author 3', '<EMAIL>', '2013-03-03 09:13:47'),
        array('Author 2', '<EMAIL>', '2013-03-03 19:55:47'),
        array('Author alias 1', '<EMAIL>', '2013-03-03 22:32:19'),
        array('Author 4', '<EMAIL>', '2013-03-04 10:32:00'),
        array('Author 4', '<EMAIL>', '2013-03-04 14:55:47'),
        array('Author 5', '<EMAIL>', '2013-03-05 09:55:47'),
        array('Author 1', '<EMAIL>', '2013-03-05 18:14:30'),
    );

    public function setUp()
    {
        $this->client = m::mock('\Gitter\Client');
        $this->gitter = m::mock('\Gitter\Repository');

        $this->client
            ->shouldReceive('getRepository')
            ->andReturn($this->gitter);

        $commits = array();
        foreach ($this->commits as $commit) {
            $commits[] = $this->createCommit($commit[0], $commit[1], $commit[2]);
        }

        $this->commits = $commits;
    }

    public function createCommit($name, $email, $date)
    {
        $author = m::mock('stdClass');
        $author
            ->shouldReceive('getName')
            ->zeroOrMoreTimes()
            ->andReturn($name)
            ->shouldReceive('getEmail')
            ->zeroOrMoreTimes()
            ->andReturn($email);

        $commit = m::mock('stdClass');
        $commit
            ->shouldReceive('getCommiterDate')
            ->zeroOrMoreTimes()
            ->andReturn(new Carbon($date))
            ->shouldReceive('getAuthor')
            ->zeroOrMoreTimes()
            ->andReturn($author);

        return $commit;
    }

    public function tearDown()
    {
        m::close();
    }

    public function createInstance()
    {
        $repo = new Repository('.', $this->client);
        $repo->commits = $this->commits;

        return $repo;
    }

    public function repositoryNames ()
    {
        return array(
            array('./some/git/repository', 'repository'),
            array('sample.git', 'sample'),
            array('../../yet-another-repository', 'yet-another-repository'),
        );
    }

    /**<commit_msg>Fixed failing getName test for Repository<commit_after><?php
namespace GitPrettyStats;

use Mockery as m;
use Carbon\Carbon;

/**
 * @covers GitPrettyStats\Repository
 */
class RepositoryTest extends \PHPUnit_Framework_TestCase
{
    public $repository;
    public $client;
    public $gitter;

    public $commits = array(
        array('Author 1', '<EMAIL>', '2013-03-01 14:55:47'),
        array('Author 1', '<EMAIL>', '2013-03-02 12:13:54'),
        array('Author 2', '<EMAIL>', '2013-03-02 14:55:47'),
        array('Author 3', '<EMAIL>', '2013-03-03 09:13:47'),
        array('Author 2', '<EMAIL>', '2013-03-03 19:55:47'),
        array('Author alias 1', '<EMAIL>', '2013-03-03 22:32:19'),
        array('Author 4', '<EMAIL>', '2013-03-04 10:32:00'),
        array('Author 4', '<EMAIL>', '2013-03-04 14:55:47'),
        array('Author 5', '<EMAIL>', '2013-03-05 09:55:47'),
        array('Author 1', '<EMAIL>', '2013-03-05 18:14:30'),
    );

    public function setUp()
    {
        $this->client = m::mock('\Gitter\Client');
        $this->gitter = m::mock('\Gitter\Repository');

        $this->client
            ->shouldReceive('getRepository')
            ->andReturn($this->gitter);

        $commits = array();
        foreach ($this->commits as $commit) {
            $commits[] = $this->createCommit($commit[0], $commit[1], $commit[2]);
        }

        $this->commits = $commits;
    }

    public function createCommit($name, $email, $date)
    {
        $author = m::mock('stdClass');
        $author
            ->shouldReceive('getName')
            ->zeroOrMoreTimes()
            ->andReturn($name)
            ->shouldReceive('getEmail')
            ->zeroOrMoreTimes()
            ->andReturn($email);

        $commit = m::mock('stdClass');
        $commit
            ->shouldReceive('getCommiterDate')
            ->zeroOrMoreTimes()
            ->andReturn(new Carbon($date))
            ->shouldReceive('getAuthor')
            ->zeroOrMoreTimes()
            ->andReturn($author);

        return $commit;
    }

    public function tearDown()
    {
        m::close();
    }

    public function createInstance()
    {
        $repo = new Repository('.', $this->client);
        $repo->commits = $this->commits;

        return $repo;
    }

    public function repositoryNames ()
    {
        return array(
            array('./some/git/repository', 'repository'),
            array('sample.git', 'sample.git'),
            array('../../yet-another-repository', 'yet-another-repository'),
        );
    }

    /**
{'fraction_non_alphanumeric': 0.1840962904498816, 'fraction_numerical': 0.060378847671665355, 'mean_word_length': 2.1981072555205046, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 71, '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': '659111', 'n_tokens_mistral': 1768, 'n_tokens_neox': 1547, 'n_words': 303}