<commit_before><?php
/**
 * CommandListShellTest file
 *
 * CakePHP :  Rapid Development Framework (http://cakephp.org)
 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          http://cakephp.org CakePHP Project
 * @since         CakePHP v 2.0
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 */
namespace Cake\Test\TestCase\Console\Command;

use Cake\Console\Command\CommandListShell;
use Cake\Console\Command\Task\CommandTask;
use Cake\Console\ConsoleOutput;
use Cake\Core\App;
use Cake\Core\Plugin;
use Cake\TestSuite\TestCase;

/**
 * Class TestStringOutput
 *
 */
class TestStringOutput extends ConsoleOutput {

	public $output = '';

	protected function _write($message) {
		$this->output .= $message;
	}

}

/**
 * Class CommandListShellTest
 *
 */
class CommandListShellTest extends TestCase {

/**
 * setUp method
 *
 * @return void
 */
	public function setUp() {
		parent::setUp();
		Plugin::load(array('TestPlugin', 'TestPluginTwo'));

		$out = new TestStringOutput();
		$in = $this->getMock('Cake\Console\ConsoleInput', array(), array(), '', false);

		$this->Shell = $this->getMock(
			'Cake\Console\Command\CommandListShell',
			array('in', '_stop', 'clear'),
			array($out, $out, $in)
		);

		$this->Shell->Command = $this->getMock(
			'Cake\Console\Command\Task\CommandTask',
			array('in', '_stop', 'clear'),
			array($out, $out, $in)
		);
	}

/**
 * tearDown
 *
 * @return void
 */
	public function tearDown() {
		parent::tearDown();
		unset($this->Shell);
		Plugin::unload();
	}

/**
 * test that main finds core shells.
 *
 * @return void
 */
	public function testMain() {
		$this->Shell->main();
		$output = $this->Shell->stdout->output;

		$expected = "/\[.*TestPlugin.*\] example/";
		$this->assertRegExp($expected, $output);

		$expected = "/\[.*TestPluginTwo.*\] example, welcome/";
		$this->assertRegExp($expected, $output);

		$expected = "/\[.*CORE.*\] bake, i18n, server, test/";
		$this->assertRegExp($expected, $output);

		$expected = "/\[.*app.*\] sample/";
		$this->assertRegExp($expected, $output);
	}

/**
 * test xml output.
 *
 * @return void
 */
	public function testMainXml() {
		$this->Shell->params['xml'] = true;
		$this->Shell->main();

		$output = $this->Shell->stdout->output;

		$find = '<shell name="sample" call_as="sample" provider="app" help="sample -h"/>';
		$this->assertContains($find, $output);

		$find = '<shell name="bake" call_as="bake" provider="CORE" help="bake -h"/>';
		$this->assertContains($find, $output);

		$find = '<shell name="welcome" call_as="TestPluginTwo.welcome" provider="TestPluginTwo" help="TestPluginTwo.welcome -h"/>';
		$this->assertContains($find, $output);
	}
}<commit_msg>Skipping test that is broken in hhvm<commit_after><?php
/**
 * CommandListShellTest file
 *
 * CakePHP :  Rapid Development Framework (http://cakephp.org)
 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          http://cakephp.org CakePHP Project
 * @since         CakePHP v 2.0
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 */
namespace Cake\Test\TestCase\Console\Command;

use Cake\Console\Command\CommandListShell;
use Cake\Console\Command\Task\CommandTask;
use Cake\Console\ConsoleOutput;
use Cake\Core\App;
use Cake\Core\Plugin;
use Cake\TestSuite\TestCase;

/**
 * Class TestStringOutput
 *
 */
class TestStringOutput extends ConsoleOutput {

	public $output = '';

	protected function _write($message) {
		$this->output .= $message;
	}

}

/**
 * Class CommandListShellTest
 *
 */
class CommandListShellTest extends TestCase {

/**
 * setUp method
 *
 * @return void
 */
	public function setUp() {
		parent::setUp();
		Plugin::load(array('TestPlugin', 'TestPluginTwo'));

		$out = new TestStringOutput();
		$in = $this->getMock('Cake\Console\ConsoleInput', array(), array(), '', false);

		$this->Shell = $this->getMock(
			'Cake\Console\Command\CommandListShell',
			array('in', '_stop', 'clear'),
			array($out, $out, $in)
		);

		$this->Shell->Command = $this->getMock(
			'Cake\Console\Command\Task\CommandTask',
			array('in', '_stop', 'clear'),
			array($out, $out, $in)
		);
	}

/**
 * tearDown
 *
 * @return void
 */
	public function tearDown() {
		parent::tearDown();
		unset($this->Shell);
		Plugin::unload();
	}

/**
 * test that main finds core shells.
 *
 * @return void
 */
	public function testMain() {
		$this->Shell->main();
		$output = $this->Shell->stdout->output;

		$expected = "/\[.*TestPlugin.*\] example/";
		$this->assertRegExp($expected, $output);

		$expected = "/\[.*TestPluginTwo.*\] example, welcome/";
		$this->assertRegExp($expected, $output);

		$expected = "/\[.*CORE.*\] bake, i18n, server, test/";
		$this->assertRegExp($expected, $output);

		$expected = "/\[.*app.*\] sample/";
		$this->assertRegExp($expected, $output);
	}

/**
 * test xml output.
 *
 * @return void
 */
	public function testMainXml() {
		$this->assertFalse(defined('HHVM_VERSION'), 'Remove when travis updates to hhvm 2.5');
		$this->Shell->params['xml'] = true;
		$this->Shell->main();

		$output = $this->Shell->stdout->output;

		$find = '<shell name="sample" call_as="sample" provider="app" help="sample -h"/>';
		$this->assertContains($find, $output);

		$find = '<shell name="bake" call_as="bake" provider="CORE" help="bake -h"/>';
		$this->assertContains($find, $output);

		$find = '<shell name="welcome" call_as="TestPluginTwo.welcome" provider="TestPluginTwo" help="TestPluginTwo.welcome -h"/>';
		$this->assertContains($find, $output);
	}
}
{'fraction_non_alphanumeric': 0.18428805237315876, 'fraction_numerical': 0.0016366612111292963, 'mean_word_length': 4.037922506183017, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 64, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4666370', 'n_tokens_mistral': 2115, 'n_tokens_neox': 1960, 'n_words': 444}