<commit_before><?php

/*
 * This file is part of the 'octris' package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace octris\command {
    use \org\octris\core\provider as provider;
    use \org\octris\core\validate as validate;

    /**
     * Execute phpunit test-suite for a project.
     *
     * @octdoc      c:command/test
     * @copyright   copyright (c) 2014 by <NAME>
     * @author      <NAME> <<EMAIL>>
     */
    class test extends \octris\command
    /**/
    {
        /**
         * Return command description.
         *
         * @octdoc  m:test/getDescription
         */
        public static function getDescription()
        /**/
        {
            return 'Execute phpunit tests.';
        }

        /**
         * Return command manual.
         *
         * @octdoc  m:create/getManual
         */
        public static function getManual()
        /**/
        {
            return <<<EOT
NAME
    octris test - execute phpunit tests.
    
SYNOPSIS
    octris test     [-f filter]
                    <project-path>
    
DESCRIPTION
    This command is used to execute the phpunit test-suite of a
    project, if available.
    
OPTIONS
    -f      Filter to apply.

EXAMPLES
    Validate a project:
    
        $ ./octris test ~/tmp/org.octris.test
EOT;
        }

        /**
         * Run command.
         *
         * @octdoc  m:test/run
         */
        public function run()
        /**/
        {
            // import required parameters
            $args = provider::access('args');

            if ($args->isExist(0) && $args->isValid(0, validate::T_PATH)) {
                $dir = $args->getValue(0) . '/tests/';
                
                if (!is_dir($dir)) {
                    $this->setError('no tests available');
                    
                    return 1;
                }
            } else {
                $this->setError('specified path is not a directory or directory not found');
                
                return 1;
            }
            
            if ($args->isExist('f') && $args->isValid('f', validate::T_PRINTABLE)) {
                $filter = '--filter ' . escapeshellarg($args->getValue('f'));
            } else {
                $filter = '';
            }
            
            if (!($cmd = `which phpunit`)) {
                $this->setError('phpunit not found');
                
                return 1;
            }<commit_msg>changes due to framework changes<commit_after><?php

/*
 * This file is part of the 'octris' package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace octris\command {
    use \org\octris\core\provider as provider;
    use \org\octris\core\validate as validate;
    use \org\octris\cliff\options as options;

    /**
     * Execute phpunit test-suite for a project.
     *
     * @octdoc      c:command/test
     * @copyright   copyright (c) 2014 by <NAME>
     * @author      <NAME> <<EMAIL>>
     */
    class test extends \org\octris\cliff\app\command
    /**/
    {
        /**
         * Constructor.
         *
         * @octdoc  m:test/__construct
         */
        public function __construct()
        /**/
        {
        }
        
        /**
         * Configure command arguments.
         *
         * @octdoc  m:test/configure
         * @param   \org\octris\cliff\options       $options            Instance of options parser.
         */
        public function configure(\org\octris\cliff\options $options)
        /**/
        {
            $options->addOption(['f', 'filter'], options::T_VALUE)->setValidator(function($value) {
                $validator = new \org\octris\core\validate\type\printable();
                return $validator->validate($validator->preFilter($value));
            }, 'invalid filter specified');
        }
        
        /**
         * Return command description.
         *
         * @octdoc  m:test/getDescription
         */
        public static function getDescription()
        /**/
        {
            return 'Execute phpunit tests.';
        }

        /**
         * Return command manual.
         *
         * @octdoc  m:test/getManual
         */
        public static function getManual()
        /**/
        {
            return <<<EOT
NAME
    octris test - execute phpunit tests.
    
SYNOPSIS
    octris test     [-f filter]
                    <project-path>
    
DESCRIPTION
    This command is used to execute the phpunit test-suite of a
    project, if available.
    
OPTIONS
    -f      Filter to apply.

EXAMPLES
    Validate a project:
    
        $ ./octris test ~/tmp/org.octris.test
EOT;
        }

        /**
         * Run command.
         *
         * @octdoc  m:test/run
         * @param   \org\octris\cliff\options\collection        $args           Parsed arguments for command.
         */
        public function run(\org\octris\cliff\options\collection $args)
        /**/
        {
            if (!isset($args[0])) {
                $this->setError(sprintf("no destination path specified"));
                
                return false;
            } elseif (!is_dir($args[0])) {
                $this->setError('specified path is not a directory or directory not found');
                
                return false;
            } else {
                $dir = $args[0] . '/tests/';
                
                if (!is_dir($dir)) {
                    $this->setError('no tests available');
                    
                    return false;
                }
            }
            
            if (isset($args['f'])) {
                $filter = '--filter ' . escapeshellarg($args['f']);
            } else {
                $filter = '';
            }
            
            if (!($cmd = `which phpunit`)) {
                $this->setError('phpunit not found');
                
                return 1;
            }
{'fraction_non_alphanumeric': 0.11659046374918354, 'fraction_numerical': 0.002939255388634879, 'mean_word_length': 1.2718842729970326, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 36, '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': '3191756', 'n_tokens_mistral': 1689, 'n_tokens_neox': 1637, 'n_words': 414}