<commit_before><?php
/**
 * TokenTest
 * 
 * @package    CodeGenerator
 * @category   Tokens
 * @author     <NAME>
 * @copyright  (c) 2012 <NAME>
 * @license    MIT License
 */
namespace CodeGenerator\Token;

class Testcase extends \CodeGenerator\Framework\Testcase
{
	/**
	 * @var  \CodeGenerator\Config
	 */
	protected $config;
	/**
	 * @var  array  Backup of the replaced helpers
	 */
	private $_backup_helpers = array();

	/**
	 * @param  array  $attributes
	 * @param  array  $options
	 */
	protected function setup_with_attributes($attributes, $options = array())
	{
		$this->setup_object($options);
		$this->set_object_attributes($this->object, $attributes);
	}

	/**
	 * @param  object  $object
	 * @param  array   $attributes
	 */
	protected function set_object_attributes($object, $attributes)
	{
		foreach ($attributes as $name => $value)
		{
			$object->set($name, $value);
		}
	}

	protected function setup_config()
	{
		$this->config = new \CodeGenerator\Config;
	}

	/**
	 * @return  array
	 */
	protected function get_class_constructor_arguments()
	{
		$this->setup_config();
		return array($this->config);
	}

	/**
	 * @param  string  $helper
	 * @param  object  $object
	 */
	protected function replace_helper($helper, $object)
	{
		if ( ! array_key_exists($helper, $this->_backup_helpers))
		{
			$current_helpers = $this->get_object_property($this->config, 'helpers')
				->getValue($this->config);
			$this->_backup_helpers[$helper] = isset($current_helpers[$helper]) ? $current_helpers[$helper] : NULL;
			$current_helpers[$helper] = $object;
			$this->get_object_property($this->config, 'helpers')<commit_msg>Added Config instance getter/lazy initializer<commit_after><?php
/**
 * TokenTest
 * 
 * @package    CodeGenerator
 * @category   Tokens
 * @author     <NAME>
 * @copyright  (c) 2012 <NAME>
 * @license    MIT License
 */
namespace CodeGenerator\Token;

class Testcase extends \CodeGenerator\Framework\Testcase
{
	/**
	 * @var  \CodeGenerator\Config
	 */
	protected $config;
	/**
	 * @var  array  Backup of the replaced helpers
	 */
	private $_backup_helpers = array();

	/**
	 * @param  array  $attributes
	 * @param  array  $options
	 */
	protected function setup_with_attributes($attributes, $options = array())
	{
		$this->setup_object($options);
		$this->set_object_attributes($this->object, $attributes);
	}

	/**
	 * @param  object  $object
	 * @param  array   $attributes
	 */
	protected function set_object_attributes($object, $attributes)
	{
		foreach ($attributes as $name => $value)
		{
			$object->set($name, $value);
		}
	}

	/**
	 * Setup config
	 */
	protected function setup_config()
	{
		$this->config = new \CodeGenerator\Config;
	}

	/**
	 * @return  \CodeGenerator\Config
	 */
	protected function get_config()
	{
		if ($this->config === NULL)
		{
			$this->setup_config();
		}
		return $this->config;
	}

	/**
	 * @return  array
	 */
	protected function get_class_constructor_arguments()
	{
		$this->setup_config();
		return array($this->config);
	}

	/**
	 * @param  string  $helper
	 * @param  object  $object
	 */
	protected function replace_helper($helper, $object)
	{
		if ( ! array_key_exists($helper, $this->_backup_helpers))
		{
			$current_helpers = $this->get_object_property($this->config, 'helpers')
				->getValue($this->config);
			$this->_backup_helpers[$helper] = isset($current_helpers[$helper]) ? $current_helpers[$helper] : NULL;
			$current_helpers[$helper] = $object;
			$this->get_object_property($this->config, 'helpers')
{'fraction_non_alphanumeric': 0.15617848970251716, 'fraction_numerical': 0.002288329519450801, 'mean_word_length': 3.810178817056396, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 42, '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': '657750', 'n_tokens_mistral': 1214, 'n_tokens_neox': 1128, 'n_words': 226}