<commit_before><?php
/*
 * Limb PHP Framework
 *
 * @link http://limb-project.com
 * @copyright  Copyright &copy; 2004-2009 BIT(http://bit-creative.com)
 * @license    LGPL http://www.gnu.org/copyleft/lesser.html
 */

 lmb_require('limb/macro/src/lmbMacroTemplate.class.php');
 lmb_require('limb/macro/src/lmbMacroConfig.class.php');

class lmbBaseMacroTest extends UnitTestCase
{
  public $base_dir;
  public $tpl_dir;
  public $cache_dir;
  public $tags_dir;
  public $filters_dir;
  
  function setUp()
  {
    $this->base_dir = LIMB_VAR_DIR . '/tpl';
    $this->tpl_dir = $this->base_dir;      
    $this->cache_dir = $this->base_dir . '/compiled';
    $this->tags_dir = dirname(__FILE__).'/../../src/tags';
    $this->filters_dir = dirname(__FILE__).'/../../src/filters';
    
    lmbFs :: rm(LIMB_VAR_DIR);
    lmbFs :: mkdir(LIMB_VAR_DIR);
    lmbFs :: mkdir($this->base_dir);
    lmbFs :: mkdir($this->tpl_dir);
    lmbFs :: mkdir($this->cache_dir);
  }

  protected function _createMacro($file)
  {
    return new lmbMacroTemplate($file, $this->_createMacroConfig());
  }

  protected function _createTemplate($code, $name = false)
  {
    if(!$name)
      $name = mt_rand() . '.phtml';    
    $file = $this->tpl_dir . '/'. $name;
    file_put_contents($file, $code);
   
    return $file;
  }

  protected function _createMacroTemplate($code, $name = false)
  {
    $file = $this->_createTemplate($code, $name);
    return $this->_createMacro($file);
  }

  protected function _createMacroConfig()
  {
    $config = array(
      'cache_dir' => $this->cache_dir,
      'forcecompile' => true,
      'forcescan' => true,     
      'tpl_scan_dirs' =>  array($this->tpl_dir),
      'tags_scan_dirs' => array('src/tags', 'limb/*/src/macro', 'limb/macro/src/tags'),
      'filters_scan_dirs' => array('src/filters', 'limb/*/src/macro', 'limb/macro/src/filters')
    );
    return new lmbMacroConfig($config);
  }
}<commit_msg>[svn r8099] -- phpDocs for lmbBaseMacroTest<commit_after><?php
/*
 * Limb PHP Framework
 *
 * @link http://limb-project.com
 * @copyright  Copyright &copy; 2004-2009 BIT(http://bit-creative.com)
 * @license    LGPL http://www.gnu.org/copyleft/lesser.html
 */

 lmb_require('limb/macro/src/lmbMacroTemplate.class.php');
 lmb_require('limb/macro/src/lmbMacroConfig.class.php');

class lmbBaseMacroTest extends UnitTestCase
{
  public $base_dir;
  public $tpl_dir;
  public $cache_dir;
  public $tags_dir;
  public $filters_dir;

  function setUp()
  {
    $this->base_dir = LIMB_VAR_DIR . '/tpl';
    $this->tpl_dir = $this->base_dir;
    $this->cache_dir = $this->base_dir . '/compiled';
    $this->tags_dir = dirname(__FILE__).'/../../src/tags';
    $this->filters_dir = dirname(__FILE__).'/../../src/filters';

    lmbFs :: rm(LIMB_VAR_DIR);
    lmbFs :: mkdir(LIMB_VAR_DIR);
    lmbFs :: mkdir($this->base_dir);
    lmbFs :: mkdir($this->tpl_dir);
    lmbFs :: mkdir($this->cache_dir);
  }

  /**
   * @param string $file
   * @return lmbMacroTemplate
   */
  protected function _createMacro($file)
  {
    return new lmbMacroTemplate($file, $this->_createMacroConfig());
  }

  /**
   * @param string $code
   * @param string $name
   * @return string filename
   */
  protected function _createTemplate($code, $name = false)
  {
    if(!$name)
      $name = mt_rand() . '.phtml';
    $file = $this->tpl_dir . '/'. $name;
    file_put_contents($file, $code);

    return $file;
  }

  /**
   * @param string $code
   * @param string $name
   * @return lmbMacroTemplate
   */
  protected function _createMacroTemplate($code, $name = false)
  {
    $file = $this->_createTemplate($code, $name);
    return $this->_createMacro($file);
  }

  /**
   * @return lmbMacroConfig
   */
  protected function _createMacroConfig()
  {
    $config = array(
      'cache_dir' => $this->cache_dir,
      'forcecompile' => true,
      'forcescan' => true,
      'tpl_scan_dirs' =>  array($this->tpl_dir),
      'tags_scan_dirs' => array('src/tags', 'limb/*/src/macro', 'limb/macro/src/tags'),
      'filters_scan_dirs' => array('src/filters', 'limb/*/src/macro', 'limb/macro/src/filters')
    );
    return new lmbMacroConfig($config);
  }
}
{'fraction_non_alphanumeric': 0.1762019230769231, 'fraction_numerical': 0.004807692307692308, 'mean_word_length': 3.2459183673469387, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '408564', 'n_tokens_mistral': 1584, 'n_tokens_neox': 1525, 'n_words': 250}