<commit_before><?php

namespace Neptune\Tests\Console;

use Neptune\Console\Console;
use Neptune\Console\DialogHelper;

use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\StreamOutput;
use Symfony\Component\Console\Helper\HelperSet;
use Symfony\Component\Console\Helper\ProgressHelper;
use Symfony\Component\Console\Helper\FormatterHelper;
use Symfony\Component\Console\Helper\TableHelper;

require_once __DIR__ . '/../../../bootstrap.php';

/**
 * ConsoleTest
 * @author <NAME> <<EMAIL>>
 */
class ConsoleTest extends \PHPUnit_Framework_TestCase {

	protected $c;
	protected $input;
	protected $output;

	public function setUp() {
		$this->input = new ArrayInput(array());
		$this->output = new StreamOutput(fopen('php://memory', 'w', false));
		$this->c = new Console($this->input, $this->output);
	}

	protected function getOutput() {
		rewind($this->output->getStream());
		$display = stream_get_contents($this->output->getStream());
		$display = str_replace(PHP_EOL, "\n", $display);
		return $display;
	}

	public function testWrite() {
		$this->c->write('Hello <info>world</info>');
		$this->assertSame('Hello world', $this->getOutput());
	}

	public function testWriteRaw() {
		$this->c->write('Hello <info>world</info>', false, StreamOutput::OUTPUT_RAW);
		$this->assertSame('Hello <info>world</info>', $this->getOutput());
	}

	public function testWritePlain() {
		$this->c->write('Hello <info>world</info>', false, StreamOutput::OUTPUT_PLAIN);
		$this->assertSame('Hello world', $this->getOutput());
	}

	public function testWriteNewline() {
		$this->c->write('Hello world', true);
		$this->assertSame("Hello world\n", $this->getOutput());
	}

	public function testWriteln() {
		$this->c->writeln('Hello world');
		$this->assertSame("Hello world\n", $this->getOutput());
	}

	public function testWritelnQuiet() {
		$this->output->setVerbosity(StreamOutput::VERBOSITY_QUIET);
		$this->c->writeln('Hello world');
		$this->assertSame('', $this->getOutput());
	}

	public function verboseProvider() {
		return array(
			array(StreamOutput::VERBOSITY_QUIET, false),
			array(StreamOutput::VERBOSITY_NORMAL, false),
			array(StreamOutput::VERBOSITY_VERBOSE, true),
			array(StreamOutput::VERBOSITY_VERY_VERBOSE, true),
			array(StreamOutput::VERBOSITY_DEBUG, true),
		);
	}

	/**
	 * @dataProvider verboseProvider()
	 */
	public function testVerbose($verbosity, $should_write) {
		$this->output->setVerbosity($verbosity);
		$this->c->verbose('Verbose message');
		if($should_write) {
			$this->assertSame("Verbose message\n", $this->getOutput());
		} else {
			$this->assertSame('', $this->getOutput());
		}
	}

	public function veryVerboseProvider() {
		return array(
			array(StreamOutput::VERBOSITY_QUIET, false),
			array(StreamOutput::VERBOSITY_NORMAL, false),
			array(StreamOutput::VERBOSITY_VERBOSE, false),
			array(StreamOutput::VERBOSITY_VERY_VERBOSE, true),
			array(StreamOutput::VERBOSITY_DEBUG, true),
		);
	}

	/**
	 * @dataProvider veryVerboseProvider()
	 */
	public function testVeryVerbose($verbosity, $should_write) {
		$this->output->setVerbosity($verbosity);
		$this->c->veryVerbose('Very verbose message');
		if($should_write) {
			$this->assertSame("Very verbose message\n", $this->getOutput());
		} else {
			$this->assertSame('', $this->getOutput());
		}
	}

	public function debugProvider() {
		return array(
			array(StreamOutput::VERBOSITY_QUIET, false),
			array(StreamOutput::VERBOSITY_NORMAL, false),
			array(StreamOutput::VERBOSITY_VERBOSE, false),
			array(StreamOutput::VERBOSITY_VERY_VERBOSE, false),
			array(StreamOutput::VERBOSITY_DEBUG, true),
		);
	}

	/**
	 * @dataProvider debugProvider()
	 */
	public function testDebug($verbosity, $should_write) {
		$this->output->setVerbosity($verbosity);
		$this->c->debug('Debug message');
		if($should_write) {
			$this->assertSame("Debug message\n", $this->getOutput());
		} else {
			$this->assertSame('', $this->getOutput());
		}
	}

	public function testGetAndSetHelperSet() {
		$helper_set = new HelperSet();<commit_msg>Testing for different output types in Console.<commit_after><?php

namespace Neptune\Tests\Console;

use Neptune\Console\Console;
use Neptune\Console\DialogHelper;

use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\StreamOutput;
use Symfony\Component\Console\Helper\HelperSet;
use Symfony\Component\Console\Helper\ProgressHelper;
use Symfony\Component\Console\Helper\FormatterHelper;
use Symfony\Component\Console\Helper\TableHelper;

require_once __DIR__ . '/../../../bootstrap.php';

/**
 * ConsoleTest
 * @author <NAME> <<EMAIL>>
 */
class ConsoleTest extends \PHPUnit_Framework_TestCase {

	protected $c;
	protected $input;
	protected $output;

	public function setUp() {
		$this->input = new ArrayInput(array());
		$this->output = new StreamOutput(fopen('php://memory', 'w', false));
		$this->c = new Console($this->input, $this->output);
	}

	protected function getOutput() {
		rewind($this->output->getStream());
		$display = stream_get_contents($this->output->getStream());
		$display = str_replace(PHP_EOL, "\n", $display);
		return $display;
	}

	public function testWrite() {
		$this->c->write('Hello <info>world</info>');
		$this->assertSame('Hello world', $this->getOutput());
	}

	public function testWriteRaw() {
		$this->c->write('Hello <info>world</info>', false, StreamOutput::OUTPUT_RAW);
		$this->assertSame('Hello <info>world</info>', $this->getOutput());
	}

	public function testWritePlain() {
		$this->c->write('Hello <info>world</info>', false, StreamOutput::OUTPUT_PLAIN);
		$this->assertSame('Hello world', $this->getOutput());
	}

	public function testWriteNewline() {
		$this->c->write('Hello world', true);
		$this->assertSame("Hello world\n", $this->getOutput());
	}

	public function testWriteln() {
		$this->c->writeln('Hello world');
		$this->assertSame("Hello world\n", $this->getOutput());
	}

	public function testWritelnRaw() {
		$this->c->writeln('Hello <info>world</info>', StreamOutput::OUTPUT_RAW);
		$this->assertSame("Hello <info>world</info>\n", $this->getOutput());
	}

	public function testWritelnPlain() {
		$this->c->writeln('Hello <info>world</info>', false, StreamOutput::OUTPUT_PLAIN);
		$this->assertSame("Hello world\n", $this->getOutput());
	}

	public function testWritelnQuiet() {
		$this->output->setVerbosity(StreamOutput::VERBOSITY_QUIET);
		$this->c->writeln('Hello world');
		$this->assertSame('', $this->getOutput());
	}

	public function verboseProvider() {
		return array(
			array(StreamOutput::VERBOSITY_QUIET, false),
			array(StreamOutput::VERBOSITY_NORMAL, false),
			array(StreamOutput::VERBOSITY_VERBOSE, true),
			array(StreamOutput::VERBOSITY_VERY_VERBOSE, true),
			array(StreamOutput::VERBOSITY_DEBUG, true),
		);
	}

	/**
	 * @dataProvider verboseProvider()
	 */
	public function testVerbose($verbosity, $should_write) {
		$this->output->setVerbosity($verbosity);
		$this->c->verbose('Verbose message');
		if($should_write) {
			$this->assertSame("Verbose message\n", $this->getOutput());
		} else {
			$this->assertSame('', $this->getOutput());
		}
	}

	/**
	 * @dataProvider verboseProvider()
	 */
	public function testVerboseRaw($verbosity, $should_write) {
		$this->output->setVerbosity($verbosity);
		$this->c->verbose('Verbose <info>message</info>', true, StreamOutput::OUTPUT_RAW);
		if($should_write) {
			$this->assertSame("Verbose <info>message</info>\n", $this->getOutput());
		} else {
			$this->assertSame('', $this->getOutput());
		}
	}

	/**
	 * @dataProvider verboseProvider()
	 */
	public function testVerbosePlain($verbosity, $should_write) {
		$this->output->setVerbosity($verbosity);
		$this->c->verbose('Verbose <info>message</info>', true, StreamOutput::OUTPUT_PLAIN);
		if($should_write) {
			$this->assertSame("Verbose message\n", $this->getOutput());
		} else {
			$this->assertSame('', $this->getOutput());
		}
	}

	public function veryVerboseProvider() {
		return array(
			array(StreamOutput::VERBOSITY_QUIET, false),
			array(StreamOutput::VERBOSITY_NORMAL, false),
			array(StreamOutput::VERBOSITY_VERBOSE, false),
			array(StreamOutput::VERBOSITY_VERY_VERBOSE, true),
			array(StreamOutput::VERBOSITY_DEBUG, true),
		);
	}

	/**
	 * @dataProvider veryVerboseProvider()
	 */
	public function testVeryVerbose($verbosity, $should_write) {
		$this->output->setVerbosity($verbosity);
		$this->c->veryVerbose('Very verbose message');
		if($should_write) {
			$this->assertSame("Very verbose message\n", $this->getOutput());
		} else {
			$this->assertSame('', $this->getOutput());
		}
	}

	/**
	 * @dataProvider veryVerboseProvider()
	 */
	public function testVeryVerboseRaw($verbosity, $should_write) {
		$this->output->setVerbosity($verbosity);
		$this->c->veryVerbose('Very verbose <info>message</info>', true, StreamOutput::OUTPUT_RAW);
		if($should_write) {
			$this->assertSame("Very verbose <info>message</info>\n", $this->getOutput());
		} else {
			$this->assertSame('', $this->getOutput());
		}
	}

	/**
	 * @dataProvider veryVerboseProvider()
	 */
	public function testVeryVerbosePlain($verbosity, $should_write) {
		$this->output->setVerbosity($verbosity);
		$this->c->veryVerbose('Very verbose <info>message</info>', true, StreamOutput::OUTPUT_PLAIN);
		if($should_write) {
			$this->assertSame("Very verbose message\n", $this->getOutput());
		} else {
			$this->assertSame('', $this->getOutput());
		}
	}

	public function debugProvider() {
		return array(
			array(StreamOutput::VERBOSITY_QUIET, false),
			array(StreamOutput::VERBOSITY_NORMAL, false),
			array(StreamOutput::VERBOSITY_VERBOSE, false),
			array(StreamOutput::VERBOSITY_VERY_VERBOSE, false),
			array(StreamOutput::VERBOSITY_DEBUG, true),
		);
	}

	/**
	 * @dataProvider debugProvider()
	 */
	public function testDebug($verbosity, $should_write) {
		$this->output->setVerbosity($verbosity);
		$this->c->debug('Debug message');
		if($should_write) {
			$this->assertSame("Debug message\n", $this->getOutput());
		} else {
			$this->assertSame('', $this->getOutput());
		}
	}

	/**
	 * @dataProvider debugProvider()
	 */
	public function testDebugRaw($verbosity, $should_write) {
		$this->output->setVerbosity($verbosity);
		$this->c->debug('Debug <info>message</info>', true, StreamOutput::OUTPUT_RAW);
		if($should_write) {
			$this->assertSame("Debug <info>message</info>\n", $this->getOutput());
		} else {
			$this->assertSame('', $this->getOutput());
		}
	}

	/**
	 * @dataProvider debugProvider()
	 */
	public function testDebugPlain($verbosity, $should_write) {
		$this->output->setVerbosity($verbosity);
		$this->c->debug('Debug <info>message</info>', true, StreamOutput::OUTPUT_PLAIN);
		if($should_write) {
			$this->assertSame("Debug message\n", $this->getOutput());
		} else {
			$this->assertSame('', $this->getOutput());
		}
	}

	public function testGetAndSetHelperSet() {
		$helper_set = new HelperSet();
{'fraction_non_alphanumeric': 0.18265343623667768, 'fraction_numerical': 0.0, 'mean_word_length': 5.459940652818991, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 223, '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': '1359114', 'n_tokens_mistral': 3927, 'n_tokens_neox': 3630, 'n_words': 570}