<commit_before><?php

/**
 * This file is part of Ratchet for CakePHP.
 *
 ** (c) 2012 - 2013 <NAME>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

App::uses('View', 'View');
App::uses('WampHelper', 'Ratchet.View/Helper');
App::uses('HtmlHelper', 'View/Helper');
App::uses('AssetCompressHelper', 'AssetCompress.View/Helper');


class RatchetHelperTest extends CakeTestCase {

/**
 * start a test
 *
 * @return void
 **/
	public function setUp() {
		parent::setUp();

		$controller = null;
		$request = new CakeRequest(null, false);
		$request->webroot = '';
		$this->view = new View($controller);
		$this->view->request = $request;
		$this->Helper = new WampHelper($this->view, array('noconfig' => true));
		$this->Helper->Html = $this->getMock('HtmlHelper', array('scriptBlock'), array($this->view));
		$this->Helper->AssetCompress = $this->getMock('AssetCompressHelper', array('script'), array($this->view, array('noconfig' => true)));

		Router::reload();
	}

/**
 * end a test
 *
 * @return void
 **/
	public function tearDown() {
		parent::tearDown();
		unset($this->Helper);
	}

/**
 * test the script includes generated by init
 *
 * @return void
 */
	public function testInit() {
		$expectedScriptBlock = "WEB_SOCKET_SWF_LOCATION = \"http://localhost/Ratchet/swf/WebSocketMain.swf\";\nvar cakeWamp = window.cakeWamp || {};\ncakeWamp.options = {retryDelay: 5000,maxRetries: 25};\nvar wsuri = \"ws://localhost:80/websocket\";";
		$this->Helper->Html->expects($this->once())
			->method('scriptBlock')
			->with($expectedScriptBlock, $this->equalTo(array(
				'inline' => false,
			)));

		$this->Helper->AssetCompress->expects($this->once())
			->method('script')
			->with($this->equalTo('Ratchet.wamp'), $this->equalTo(array('block' => 'script')));

		$this->Helper->init();
	}

}
<commit_msg>Configure values for the Helper test<commit_after><?php

/**
 * This file is part of Ratchet for CakePHP.
 *
 ** (c) 2012 - 2013 <NAME>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

App::uses('View', 'View');
App::uses('WampHelper', 'Ratchet.View/Helper');
App::uses('HtmlHelper', 'View/Helper');
App::uses('AssetCompressHelper', 'AssetCompress.View/Helper');


class RatchetHelperTest extends CakeTestCase {

/**
 * start a test
 *
 * @return void
 **/
	public function setUp() {
		parent::setUp();

		$controller = null;
		$request = new CakeRequest(null, false);
		$request->webroot = '';
		$this->view = new View($controller);
		$this->view->request = $request;
		$this->Helper = new WampHelper($this->view, array('noconfig' => true));
		$this->Helper->Html = $this->getMock('HtmlHelper', array('scriptBlock'), array($this->view));
		$this->Helper->AssetCompress = $this->getMock('AssetCompressHelper', array('script'), array($this->view, array('noconfig' => true)));

		Router::reload();

		Configure::write('Ratchet', array(
			'Client' => array(
				'retryDelay' => 5000, // Not the best option but it speeds up development
				'maxRetries' => 25, // Keep on trying! (Also not the best option)
			),
			'Connection' => array(
				'external' => array(
					'hostname' => 'localhost',
					'port' => 80,
					'path' => 'websocket',
					'secure' => false,
				),
			),
		));
	}

/**
 * end a test
 *
 * @return void
 **/
	public function tearDown() {
		parent::tearDown();
		unset($this->Helper);
	}

/**
 * test the script includes generated by init
 *
 * @return void
 */
	public function testInit() {
		$expectedScriptBlock = "WEB_SOCKET_SWF_LOCATION = \"http://localhost/Ratchet/swf/WebSocketMain.swf\";\nvar cakeWamp = window.cakeWamp || {};\ncakeWamp.options = {retryDelay: 5000,maxRetries: 25};\nvar wsuri = \"ws://localhost:80/websocket\";";
		$this->Helper->Html->expects($this->once())
			->method('scriptBlock')
			->with($expectedScriptBlock, $this->equalTo(array(
				'inline' => false,
			)));

		$this->Helper->AssetCompress->expects($this->once())
			->method('script')
			->with($this->equalTo('Ratchet.wamp'), $this->equalTo(array('block' => 'script')));

		$this->Helper->init();
	}

}

{'fraction_non_alphanumeric': 0.1991404011461318, 'fraction_numerical': 0.009551098376313277, 'mean_word_length': 4.363636363636363, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 86, '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': '809642', 'n_tokens_mistral': 1534, 'n_tokens_neox': 1373, 'n_words': 294}