<commit_before><?php
/**
 * Unit Test Case that covers the Dependency Model representative.
 *
 * PHP version 5
 *
 * @category   PHP
 * @package    PHP_Reflect
 * @subpackage Tests
 * @author     Laurent Laville <<EMAIL>>
 * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
 * @version    GIT: $Id$
 * @link       http://php5.laurent-laville.org/reflect/
 * @since      Class available since Release 2.2.0
 */

namespace Bartlett\Tests\Reflect\Model;

use Bartlett\Reflect;
use Bartlett\Reflect\ProviderManager;
use Bartlett\Reflect\Provider\SymfonyFinderProvider;
use Symfony\Component\Finder\Finder;

if (!defined('TEST_FILES_PATH')) {
    define(
        'TEST_FILES_PATH',
        dirname(__DIR__) . DIRECTORY_SEPARATOR .
        '_files' . DIRECTORY_SEPARATOR
    );
}

/**
 * Unit Test Case that covers Bartlett\Reflect\Model\DependencyModel
 *
 * @category   PHP
 * @package    PHP_Reflect
 * @subpackage Tests
 * @author     Laurent Laville <<EMAIL>>
 * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
 * @version    Release: @package_version@
 * @link       http://php5.laurent-laville.org/reflect/
 */
class DependencyModelTest extends \PHPUnit_Framework_TestCase
{
    protected static $dependencies;

    /**
     * Sets up the shared fixture.
     *
     * @return void
     * @link   http://phpunit.de/manual/current/en/fixtures.html#fixtures.sharing-fixture
     */
    public static function setUpBeforeClass()
    {
        $finder = new Finder();
        $finder->files()
            ->name('dependencies.php')
            ->in(TEST_FILES_PATH);

        $pm = new ProviderManager;
        $pm->set('test_files', new SymfonyFinderProvider($finder));

        $reflect = new Reflect();
        $reflect->setProviderManager($pm);
        $reflect->parse();

        foreach ($reflect->getPackages() as $package) {
            foreach ($package->getDependencies() as $rd) {
                self::$dependencies[] = $rd;
            }
        }
    }

    /**
     * Tests starting line number accessor.
     *
     *  covers DependencyModel::getStartLine
     * @return void
     */
    public function testStartLineAccessor()
    {
        $d = 0;  // DateTime::diff

        $this->assertEquals(
            5,
            self::$dependencies[$d]->getStartLine(),
            self::$dependencies[$d]->getName()
            . ' starting line does not match.'
        );
    }

    /**
     * Tests ending line number accessor.
     *
     *  covers DependencyModel::getEndLine
     * @return void
     */
    public function testEndLineAccessor()
    {
        $d = 0;  // DateTime::diff

        $this->assertEquals(
            6,
            self::$dependencies[$d]->getEndLine(),
            self::$dependencies[$d]->getName()
            . ' ending line does not match.'
        );
    }

    /**
     * Tests file name accessor.
     *
     *  covers DependencyModel::getFileName
     * @return void
     */
    public function testFileNameAccessor()
    {
        $d = 0;  // DateTime::diff

        $this->assertEquals(
            TEST_FILES_PATH . 'dependencies.php',
            self::$dependencies[$d]->getFileName(),
            self::$dependencies[$d]->getName()
            . ' file name does not match.'
        );
    }

    /**
     * Tests method name accessor.
     *
     *  covers DependencyModel::getName
     * @return void
     */
    public function testNameAccessor()
    {
        $d = 0;  // DateTime::diff

        $this->assertEquals(
            'DateTime::diff',
            self::$dependencies[$d]->getName(),
            self::$dependencies[$d]->getName()
            . ' dependency name does not match.'
        );
    }

    /**
     * Tests the namespace name accessor.
     *
     *  covers DependencyModel::getNamespaceName
     * @return void
     */
    public function testNamespaceNameAccessor()
    {
        $d = 0;  // DateTime::diff

        $this->assertEquals(
            '',
            self::$dependencies[$d]->getNamespaceName(),
            self::$dependencies[$d]->getName() . ' namespace does not match.'
        );
    }

    /**
     * Tests if the dependency is a class method.
     *
     *  covers DependencyModel::isClassMethod
     * @return void
     */
    public function testClassMethod()
    {
        $d = 0;  // DateTime::diff

        $this->assertTrue(
            self::$dependencies[$d]->isClassMethod(),
            self::$dependencies[$d]->getName() . ' is not a class method.'
        );
    }

    /**
     * Tests if the dependency is a php/extension function.
     *
     *  covers DependencyModel::isInternalFunction
     * @return void
     */
    public function testInternalFunction()
    {
        $d = 2;  // extension_loaded

        $this->assertTrue(
            self::$dependencies[$d]->isInternalFunction(),
            self::$dependencies[$d]->getName() . ' is not an internal function.'
        );
    }

    /**
     * Tests arguments list of a dependency.
     *
     *  covers DependencyModel::getArguments
     * @return void
     */
    public function testArgumentsAccessor()
    {
        $d = 2;  // extension_loaded
        $p = 0;

        $args = self::$dependencies[$d]->getArguments();

        $this->assertEquals(
            'date',
            $args[$p]['value'],
            self::$dependencies[$d]->getName()
            . " argument #$p value does not match."
        );
    }
}<commit_msg>with commit a4cab6d, only ClassModel are attached to classes category, so reindex test cases<commit_after><?php
/**
 * Unit Test Case that covers the Dependency Model representative.
 *
 * PHP version 5
 *
 * @category   PHP
 * @package    PHP_Reflect
 * @subpackage Tests
 * @author     <NAME> <<EMAIL>>
 * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
 * @version    GIT: $Id$
 * @link       http://php5.laurent-laville.org/reflect/
 * @since      Class available since Release 2.2.0
 */

namespace Bartlett\Tests\Reflect\Model;

use Bartlett\Reflect;
use Bartlett\Reflect\ProviderManager;
use Bartlett\Reflect\Provider\SymfonyFinderProvider;
use Symfony\Component\Finder\Finder;

if (!defined('TEST_FILES_PATH')) {
    define(
        'TEST_FILES_PATH',
        dirname(__DIR__) . DIRECTORY_SEPARATOR .
        '_files' . DIRECTORY_SEPARATOR
    );
}

/**
 * Unit Test Case that covers Bartlett\Reflect\Model\DependencyModel
 *
 * @category   PHP
 * @package    PHP_Reflect
 * @subpackage Tests
 * @author     <NAME> <<EMAIL>>
 * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
 * @version    Release: @package_version@
 * @link       http://php5.laurent-laville.org/reflect/
 */
class DependencyModelTest extends \PHPUnit_Framework_TestCase
{
    protected static $dependencies;

    /**
     * Sets up the shared fixture.
     *
     * @return void
     * @link   http://phpunit.de/manual/current/en/fixtures.html#fixtures.sharing-fixture
     */
    public static function setUpBeforeClass()
    {
        $finder = new Finder();
        $finder->files()
            ->name('dependencies.php')
            ->in(TEST_FILES_PATH);

        $pm = new ProviderManager;
        $pm->set('test_files', new SymfonyFinderProvider($finder));

        $reflect = new Reflect();
        $reflect->setProviderManager($pm);
        $reflect->parse();

        foreach ($reflect->getPackages() as $package) {
            foreach ($package->getDependencies() as $rd) {
                self::$dependencies[] = $rd;
            }
        }
    }

    /**
     * Tests starting line number accessor.
     *
     *  covers DependencyModel::getStartLine
     * @return void
     */
    public function testStartLineAccessor()
    {
        $d = 1;  // DateTime::diff

        $this->assertEquals(
            5,
            self::$dependencies[$d]->getStartLine(),
            self::$dependencies[$d]->getName()
            . ' starting line does not match.'
        );
    }

    /**
     * Tests ending line number accessor.
     *
     *  covers DependencyModel::getEndLine
     * @return void
     */
    public function testEndLineAccessor()
    {
        $d = 1;  // DateTime::diff

        $this->assertEquals(
            6,
            self::$dependencies[$d]->getEndLine(),
            self::$dependencies[$d]->getName()
            . ' ending line does not match.'
        );
    }

    /**
     * Tests file name accessor.
     *
     *  covers DependencyModel::getFileName
     * @return void
     */
    public function testFileNameAccessor()
    {
        $d = 1;  // DateTime::diff

        $this->assertEquals(
            TEST_FILES_PATH . 'dependencies.php',
            self::$dependencies[$d]->getFileName(),
            self::$dependencies[$d]->getName()
            . ' file name does not match.'
        );
    }

    /**
     * Tests method name accessor.
     *
     *  covers DependencyModel::getName
     * @return void
     */
    public function testNameAccessor()
    {
        $d = 1;  // DateTime::diff

        $this->assertEquals(
            'DateTime::diff',
            self::$dependencies[$d]->getName(),
            self::$dependencies[$d]->getName()
            . ' dependency name does not match.'
        );
    }

    /**
     * Tests the namespace name accessor.
     *
     *  covers DependencyModel::getNamespaceName
     * @return void
     */
    public function testNamespaceNameAccessor()
    {
        $d = 1;  // DateTime::diff

        $this->assertEquals(
            '',
            self::$dependencies[$d]->getNamespaceName(),
            self::$dependencies[$d]->getName() . ' namespace does not match.'
        );
    }

    /**
     * Tests if the dependency is a class method.
     *
     *  covers DependencyModel::isClassMethod
     * @return void
     */
    public function testClassMethod()
    {
        $d = 1;  // DateTime::diff

        $this->assertTrue(
            self::$dependencies[$d]->isClassMethod(),
            self::$dependencies[$d]->getName() . ' is not a class method.'
        );
    }

    /**
     * Tests if the dependency is a php/extension function.
     *
     *  covers DependencyModel::isInternalFunction
     * @return void
     */
    public function testInternalFunction()
    {
        $d = 3;  // extension_loaded

        $this->assertTrue(
            self::$dependencies[$d]->isInternalFunction(),
            self::$dependencies[$d]->getName() . ' is not an internal function.'
        );
    }

    /**
     * Tests arguments list of a dependency.
     *
     *  covers DependencyModel::getArguments
     * @return void
     */
    public function testArgumentsAccessor()
    {
        $d = 3;  // extension_loaded
        $p = 0;

        $args = self::$dependencies[$d]->getArguments();

        $this->assertEquals(
            'date',
            $args[$p]['value'],
            self::$dependencies[$d]->getName()
            . " argument #$p value does not match."
        );
    }
}
{'fraction_non_alphanumeric': 0.13332122423031514, 'fraction_numerical': 0.00326945781491236, 'mean_word_length': 1.9956474428726878, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 77, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '652950', 'n_tokens_mistral': 3155, 'n_tokens_neox': 3069, 'n_words': 665}