<commit_before><?php

/*
 * This file is part of Alt Three TestBench.
 *
 * (c) Alt Three Services Limited
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace AltThree\Tests\TestBench\Analysis;

use AltThree\TestBench\Analysis\ClassInspector;
use AltThree\TestBench\AnemicTrait;
use PhpParser\NodeTraverserInterface;
use PHPUnit_Framework_TestCase as TestCase;

class ClassInspectorTest extends TestCase
{
    public function testCanInspectClasses()
    {
        $inspector = ClassInspector::inspect(static::class);

        $this->assertInstanceOf(ClassInspector::class, $inspector);

        $this->assertTrue($inspector->isClass());
        $this->assertFalse($inspector->isInterface());
        $this->assertFalse($inspector->isTrait());
        $this->assertTrue($inspector->exists());

        $this->assertSame([
            'AltThree\TestBench\Analysis\ClassInspector',
            'AltThree\TestBench\AnemicTrait',
            'PhpParser\NodeTraverserInterface',
            'PHPUnit_Framework_TestCase',
        ], $inspector->references());
    }

    public function testCanInspectInterfaces()
    {
        $inspector = ClassInspector::inspect(NodeTraverserInterface::class);

        $this->assertInstanceOf(ClassInspector::class, $inspector);

        $this->assertFalse($inspector->isClass());
        $this->assertTrue($inspector->isInterface());
        $this->assertFalse($inspector->isTrait());
        $this->assertTrue($inspector->exists());

        $this->assertSame(['PhpParser\NodeVisitor'], $inspector->references());
    }

    public function testCanInspectTraits()
    {
        $inspector = ClassInspector::inspect(AnemicTrait::class);

        $this->assertInstanceOf(ClassInspector::class, $inspector);

        $this->assertFalse($inspector->isClass());
        $this->assertFalse($inspector->isInterface());
        $this->assertTrue($inspector->isTrait());
        $this->assertTrue($inspector->exists());

        $this->assertSame([
            'ReflectionClass',
            'ReflectionException',
            'ReflectionParameter',
            'ReflectionProperty',
            'AltThree\TestBench\ExpectsTrait',
        ], $inspector->references());
    }

    public function testCanInspectNothing()
    {
        $inspector = ClassInspector::inspect('foobarbaz');

        $this->assertInstanceOf(ClassInspector::class, $inspector);

        $this->assertFalse($inspector->isClass());
        $this->assertFalse($inspector->isInterface());
        $this->assertFalse($inspector->isTrait());
        $this->assertFalse($inspector->exists());

        $this->assertSame([], $inspector->references());
    }
}<commit_msg>Fixed the tests<commit_after><?php

/*
 * This file is part of Alt Three TestBench.
 *
 * (c) Alt Three Services Limited
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace AltThree\Tests\TestBench\Analysis;

use AltThree\TestBench\Analysis\ClassInspector;
use AltThree\TestBench\AnemicTrait;
use PhpParser\NodeTraverserInterface;
use PHPUnit_Framework_TestCase as TestCase;

class ClassInspectorTest extends TestCase
{
    public function testCanInspectClasses()
    {
        $inspector = ClassInspector::inspect(static::class);

        $this->assertInstanceOf(ClassInspector::class, $inspector);

        $this->assertTrue($inspector->isClass());
        $this->assertFalse($inspector->isInterface());
        $this->assertFalse($inspector->isTrait());
        $this->assertTrue($inspector->exists());

        $this->assertSame([
            'AltThree\TestBench\Analysis\ClassInspector',
            'AltThree\TestBench\AnemicTrait',
            'PhpParser\NodeTraverserInterface',
            'PHPUnit_Framework_TestCase',
        ], $inspector->references());
    }

    public function testCanInspectInterfaces()
    {
        $inspector = ClassInspector::inspect(NodeTraverserInterface::class);

        $this->assertInstanceOf(ClassInspector::class, $inspector);

        $this->assertFalse($inspector->isClass());
        $this->assertTrue($inspector->isInterface());
        $this->assertFalse($inspector->isTrait());
        $this->assertTrue($inspector->exists());

        $this->assertSame(['PhpParser\NodeVisitor'], $inspector->references());
    }

    public function testCanInspectTraits()
    {
        $inspector = ClassInspector::inspect(AnemicTrait::class);

        $this->assertInstanceOf(ClassInspector::class, $inspector);

        $this->assertFalse($inspector->isClass());
        $this->assertFalse($inspector->isInterface());
        $this->assertTrue($inspector->isTrait());
        $this->assertTrue($inspector->exists());

        $this->assertSame([
            'ReflectionClass',
            'ReflectionException',
            'ReflectionParameter',
            'ReflectionProperty',
            'AltThree\TestBench\ExpectsTrait',
            'AltThree\TestBench\ValidationTrait',
        ], $inspector->references());
    }

    public function testCanInspectNothing()
    {
        $inspector = ClassInspector::inspect('foobarbaz');

        $this->assertInstanceOf(ClassInspector::class, $inspector);

        $this->assertFalse($inspector->isClass());
        $this->assertFalse($inspector->isInterface());
        $this->assertFalse($inspector->isTrait());
        $this->assertFalse($inspector->exists());

        $this->assertSame([], $inspector->references());
    }
}
{'fraction_non_alphanumeric': 0.14401294498381878, 'fraction_numerical': 0.0, 'mean_word_length': 3.415079365079365, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 91, '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': '4723892', 'n_tokens_mistral': 1603, 'n_tokens_neox': 1527, 'n_words': 223}