<commit_before><?php

use \Aensley\YahooStockQuotes\YahooStockQuotes;

class YahooStockQuotesTest extends \PHPUnit_Framework_TestCase {

	public $symbol = 'YHOO';
	public $stockQuotes;

	protected function setUp() {
		$this->stockQuotes = new YahooStockQuotes(array($this->symbol));
	}

	public function testInstantiation() {
		$this->assertInstanceOf('\Aensley\YahooStockQuotes\YahooStockQuotes', $this->stockQuotes);
	}

	public function testEmptyInstantiation() {
		$this->assertInstanceOf('\Aensley\YahooStockQuotes\YahooStockQuotes', new YahooStockQuotes);
	}

	public function testUnknownPrice() {
		$this->assertEquals('Unknown', $this->stockQuotes->getPrice('invalid_symbol'));
	}

	public function testUnknownChange() {
		$this->assertEquals('Unknown', $this->stockQuotes->getChange('invalid_symbol'));
	}

	public function testGetPrice() {
		$price = $this->stockQuotes->getPrice($this->symbol);
		$this->assertInternalType('string', $price);
		// Example: $10.31 or $234,563.433333
		$this->assertRegExp('/^\$\d+(?:,\d{3})?\.\d+$/', $price);
	}

	public function testGetChange() {
		$change = $this->stockQuotes->getChange($this->symbol);
		$this->assertInternalType('string', $change);
		// Example: +13.38% or -0.0002%
		$this->assertRegExp('/^[+-]\d+\.\d+%$/', $change);
	}

	public function testGetUpdatedDate() {
		$date = $this->stockQuotes->getUpdatedDate('Y-m-d H:i:s');
		$this->assertInternalType('string', $date);
		// Example: 2016-04-12 07:22:14
		$this->assertRegExp('/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/', $date);
	}
}<commit_msg>Fixed testing setup.<commit_after><?php

use \Aensley\YahooStockQuotes\YahooStockQuotes;

class YahooStockQuotesTest extends \PHPUnit_Framework_TestCase {

	public $symbol = 'YHOO';
	public $stockQuotes;

	protected function setUp() {
		ini_set('allow_url_fopen', 'Off');
		$this->clearCache();
		$this->stockQuotes = new YahooStockQuotes(array($this->symbol));
	}

	public function testInstantiation() {
		$this->assertInstanceOf('\Aensley\YahooStockQuotes\YahooStockQuotes', $this->stockQuotes);
	}

	public function testEmptyInstantiation() {
		$this->assertInstanceOf('\Aensley\YahooStockQuotes\YahooStockQuotes', new YahooStockQuotes);
	}

	public function testUnknownPrice() {
		$this->assertEquals('Unknown', $this->stockQuotes->getPrice('invalid_symbol'));
	}

	public function testUnknownChange() {
		$this->assertEquals('Unknown', $this->stockQuotes->getChange('invalid_symbol'));
	}

	public function testGetPrice() {
		$price = $this->stockQuotes->getPrice($this->symbol);
		$this->assertInternalType('string', $price);
		// Example: $10.31 or $234,563.433333
		$this->assertRegExp('/^\$\d+(?:,\d{3})?\.\d+$/', $price);
	}

	public function testGetChange() {
		$change = $this->stockQuotes->getChange($this->symbol);
		$this->assertInternalType('string', $change);
		// Example: +13.38% or -0.0002%
		$this->assertRegExp('/^[+-]\d+\.\d+%$/', $change);
	}

	public function testGetUpdatedDate() {
		$date = $this->stockQuotes->getUpdatedDate('Y-m-d H:i:s');
		$this->assertInternalType('string', $date);
		// Example: 2016-04-12 07:22:14
		$this->assertRegExp('/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/', $date);
	}

	private function clearCache() {
		file_put_contents(__DIR__ . '/../../../src/Aensley/YahooStockQuotes/YahooStockQuotes.json', '');
	}

	protected function tearDown() {
		$this->clearCache();
	}
}
{'fraction_non_alphanumeric': 0.20112392783200236, 'fraction_numerical': 0.027210884353741496, 'mean_word_length': 5.297951582867784, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 55, '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': '4437780', 'n_tokens_mistral': 1323, 'n_tokens_neox': 1187, 'n_words': 172}