<commit_before><?php
namespace NamelessCoder\GizzleGitPlugins\Tests\Unit\GizzlePlugins;
use NamelessCoder\Gizzle\Payload;
use NamelessCoder\GizzleGitPlugins\GizzlePlugins\PullPlugin;

/**
 * Class PullPluginTest
 */
class PullPluginTest extends \PHPUnit_Framework_TestCase {

	/**
	 * @dataProvider getTriggerTestSettingsAndPayloads
	 * @param array $settings
	 * @param Payload $payload<commit_msg>[TASK] Finish test for PullPlugin<commit_after><?php
namespace NamelessCoder\GizzleGitPlugins\Tests\Unit\GizzlePlugins;

use NamelessCoder\Gizzle\Payload;
use NamelessCoder\GizzleGitPlugins\GizzlePlugins\PullPlugin;

/**
 * Class PullPluginTest
 */
class PullPluginTest extends \PHPUnit_Framework_TestCase {

	public function testProcessCallsExpectedMethodSequence() {
		$expectedCommandArray = array('cd', "'.'", '&&', 'foobar', 'pull', "'foobar'", "'master'");
		$plugin = $this->getMock('NamelessCoder\\GizzleGitPlugins\\GizzlePlugins\\PullPlugin', array('resolveGitCommand', 'executeGitCommand'));
		$plugin->expects($this->once())->method('resolveGitCommand')->will($this->returnValue('foobar'));
		$plugin->expects($this->once())->method('executeGitCommand')->with($expectedCommandArray)->will($this->returnValue(array('foo')));
		$response = $this->getMock('NamelessCoder\\Gizzle\\Response', array('addOutputFromPlugin'));
		$response->expects($this->once())->method('addOutputFromPlugin')->with($plugin, array('foo'));
		$repository = $this->getMock('NamelessCoder\\Gizzle\\Repository', array('getMasterBranch', 'getUrl'));
		$repository->expects($this->any())->method('getMasterBranch')->will($this->returnValue('master'));
		$repository->expects($this->any())->method('getUrl')->will($this->returnValue('foobar'));
		$payload = $this->getMock('NamelessCoder\\Gizzle\\Payload', array('getRepository', 'getResponse'), array(), '', FALSE);
		$payload->expects($this->any())->method('getRepository')->will($this->returnValue($repository));
		$payload->expects($this->once())->method('getResponse')->will($this->returnValue($response));
		$settings = $this->getSettingsFor('foobar', 'master');
		$settings[PullPlugin::OPTION_DIRECTORY] = '.';
		$plugin->initialize($settings);
		$plugin->process($payload);
	}

	public function testProcessThrowsErrorWhenNoDirectoryIsConfigured() {
		$plugin = new PullPlugin();
		$repository = $this->getMock('NamelessCoder\\Gizzle\\Repository', array('getMasterBranch', 'getUrl'));
		$repository->expects($this->any())->method('getMasterBranch')->will($this->returnValue('master'));
		$repository->expects($this->any())->method('getUrl')->will($this->returnValue('foobar'));
		$payload = $this->getMock('NamelessCoder\\Gizzle\\Payload', array('getRepository'), array(), '', FALSE);
		$payload->expects($this->any())->method('getRepository')->will($this->returnValue($repository));
		$this->setExpectedException('RuntimeException');
		$plugin->process($payload);
	}

	/**
	 * @dataProvider getTriggerTestSettingsAndPayloads
	 * @param array $settings
	 * @param Payload $payload
{'fraction_non_alphanumeric': 0.19827586206896552, 'fraction_numerical': 0.0, 'mean_word_length': 8.087349397590362, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 64, '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': '19061', 'n_tokens_mistral': 959, 'n_tokens_neox': 913, 'n_words': 105}