<commit_before><?php namespace Franzose\ClosureTable\Tests;

use \Mockery;
use \Illuminate\Container\Container as App;
use \Franzose\ClosureTable\Contracts\EntityInterface;
use \Franzose\ClosureTable\Models\Entity;
use \Franzose\ClosureTable\Models\ClosureTable;

class EntityTestCase extends BaseTestCase {
    /**
     * @var Entity;
     */
    protected $entity;

    /**
     * @var Mockery\MockInterface|\Yay_MockObject
     */
    protected $closure;

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

        $this->entity = new Entity;
        $this->app->instance('Franzose\ClosureTable\Contracts\ClosureTableInterface', new ClosureTable);
    }

    public function testPositionIsFillable()
    {
        $this->assertContains(Entity::POSITION, $this->entity->getFillable());
    }

    public function testPositionDefaultValue()
    {
        $this->assertEquals(0, $this->entity->{Entity::POSITION});
    }

    public function testIsParent()
    {
        $this->assertFalse($this->entity->isParent());
    }

    public function testIsRoot()
    {
        $this->assertTrue($this->entity->isRoot());
    }

    /**
     * @expectedException \InvalidArgumentException
     */
    public function testMoveToThrowsException()
    {
        $this->entity->moveTo(0, $this->entity);
    }

    public function testMoveTo()
    {
        $closure = Mockery::mock('Franzose\ClosureTable\Models\ClosureTable');
        $this->app->instance('Franzose\ClosureTable\Contracts\ClosureTableInterface', $closure);

        $closure->shouldReceive('moveNodeTo')
            ->with(Mockery::type('int'))
            ->andReturn(Mockery::type('bool'));

        $ancestor = Mockery::mock('Franzose\ClosureTable\Models\Entity');
        $ancestor->shouldReceive('getKey')->andReturn(1);

        $result = $this->entity->moveTo(5, $ancestor);
        $this->assertSame($this->entity, $result);
        $this->assertEquals(5, $result->{Entity::POSITION});
    }

    public function testGetParent()
    {
        $entity = Entity::find(10);
        $parent = $entity->getParent();

        $this->assertInstanceOf('Franzose\ClosureTable\Models\Entity', $parent);
        $this->assertEquals(9, $parent->getKey());
    }
<commit_msg>removed mocks from testMoveTo method<commit_after><?php namespace Franzose\ClosureTable\Tests;

use \Mockery;
use \Illuminate\Container\Container as App;
use \Franzose\ClosureTable\Contracts\EntityInterface;
use \Franzose\ClosureTable\Models\Entity;
use \Franzose\ClosureTable\Models\ClosureTable;

class EntityTestCase extends BaseTestCase {
    /**
     * @var Entity;
     */
    protected $entity;

    /**
     * @var Mockery\MockInterface|\Yay_MockObject
     */
    protected $closure;

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

        $this->entity = new Entity;
        $this->app->instance('Franzose\ClosureTable\Contracts\ClosureTableInterface', new ClosureTable);
    }

    public function testPositionIsFillable()
    {
        $this->assertContains(Entity::POSITION, $this->entity->getFillable());
    }

    public function testPositionDefaultValue()
    {
        $this->assertEquals(0, $this->entity->{Entity::POSITION});
    }

    public function testIsParent()
    {
        $this->assertFalse($this->entity->isParent());
    }

    public function testIsRoot()
    {
        $this->assertTrue($this->entity->isRoot());
    }

    /**
     * @expectedException \InvalidArgumentException
     */
    public function testMoveToThrowsException()
    {
        $this->entity->moveTo(0, $this->entity);
    }

    public function testMoveTo()
    {
        $ancestor = Entity::find(1);
        $result = $this->entity->moveTo(5, $ancestor);
        
        $this->assertSame($this->entity, $result);
        $this->assertEquals(5, $result->{Entity::POSITION});
        $this->assertEquals($this->entity->getParent()->getKey(), $ancestor->getKey());
    }

    public function testGetParent()
    {
        $entity = Entity::find(10);
        $parent = $entity->getParent();

        $this->assertInstanceOf('Franzose\ClosureTable\Models\Entity', $parent);
        $this->assertEquals(9, $parent->getKey());
    }

{'fraction_non_alphanumeric': 0.15165989968951515, 'fraction_numerical': 0.0038213518032003822, 'mean_word_length': 3.0230547550432276, 'pattern_counts': {'":': 0, '<': 5, '<?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': '780538', 'n_tokens_mistral': 1276, 'n_tokens_neox': 1235, 'n_words': 184}