<commit_before><?php
/**
 * This file is part of the sfImageTransformExtraPlugin unit tests package.
 * (c) 2010 <NAME> <<EMAIL>>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @package    sfImageTransformExtraPluginUnitTests
 * @author     <NAME> <<EMAIL>>
 * @version    SVN: $Id: sfRawFileCache.class.php 63 2010-03-09 04:34:28Z caefer $
 */

/** central bootstrap for unit tests */
require_once dirname(__FILE__).'/../../bootstrap/unit.php';
/** PHPUnit Framework */
require_once 'PHPUnit/Framework.php';

/**
 * PHPUnit test for sfImageTransformExtraPluginConfiguration
 *
 * @package    sfImageTransformExtraPluginUnitTests
 * @subpackage config
 * @author     <NAME> <<EMAIL>>
 */
class sfImageTransformExtraPluginConfigurationTest extends PHPUnit_Framework_TestCase
{
  public function testInitialize()
  {
    $dispatcher = $this->projectConfiguration->getEventDispatcher();
    $load_factories = count($dispatcher->getListeners('context.load_factories'));
    $change_action = count($dispatcher->getListeners('controller.change_action'));
    $changed_source = count($dispatcher->getListeners('sf_image_transform.changed_source'));

    $this->pluginConfiguration->initialize();

    $this->assertEquals($load_factories + 1, count($dispatcher->getListeners('context.load_factories')));
    $this->assertEquals($change_action + 1, count($dispatcher->getListeners('controller.change_action')));
    $this->assertEquals($changed_source + 1, count($dispatcher->getListeners('sf_image_transform.changed_source')));
  }

  public function testSetCacheKey()
  {
    $internalUri = 'sfImageTransformator/index?type=TestFile&format=original&path=00/00/00&slug=barfoo&id=1&sf_format=jpg';
    $viewCacheManager = new sfViewCacheManager(sfContext::getInstance(), new sfNoCache());
    $path = sfImageTransformExtraPluginConfiguration::setCacheKey($internalUri, '', '', '', $viewCacheManager);
    $this->assertContains('/thumbnails/TestFile/original/00/00/00/barfoo-1.jpg', $path);
  }

  public function testSetViewCache()
  {
    $this->markTestSkipped('ViewCacheManagers can not be tested from command line');
  }

  public function testGetCache()
  {
    $this->assertType('sfRawFileCache', sfImageTransformExtraPluginConfiguration::getCache());
  }

  public function testRegisterStreamWrapper()
  {
    stream_wrapper_unregister('sfImageSource');
    $event = new sfEvent($this, 'context.load_factories', array());
    sfImageTransformExtraPluginConfiguration::registerStreamWrapper($event);
    $this->assertTrue(in_array('sfImageSource', stream_get_wrappers()));
  }

  public function testRemoveOldThumbnails()
  {
    //$event = new sfEvent($this, 'sf_image_transform.changed_source', array());
    //sfImageTransformExtraPluginConfiguration::registerStreamWrapper($event);
    $this->markTestIncomplete('Removal not yet implemented');<commit_msg>Unit Tests for sfImageTransformExtraPluginConfiguration are green again<commit_after><?php
/**
 * This file is part of the sfImageTransformExtraPlugin unit tests package.
 * (c) 2010 <NAME> <<EMAIL>>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @package    sfImageTransformExtraPluginUnitTests
 * @author     <NAME> <<EMAIL>>
 * @version    SVN: $Id: sfRawFileCache.class.php 63 2010-03-09 04:34:28Z caefer $
 */

/** central bootstrap for unit tests */
require_once dirname(__FILE__).'/../../bootstrap/unit.php';
/** PHPUnit Framework */
require_once 'PHPUnit/Framework.php';

/**
 * PHPUnit test for sfImageTransformExtraPluginConfiguration
 *
 * @package    sfImageTransformExtraPluginUnitTests
 * @subpackage config
 * @author     <NAME> <<EMAIL>>
 */
class sfImageTransformExtraPluginConfigurationTest extends PHPUnit_Framework_TestCase
{
  public function testInitialize()
  {
    $dispatcher = $this->projectConfiguration->getEventDispatcher();
    $change_action = count($dispatcher->getListeners('controller.change_action'));
    $changed_source = count($dispatcher->getListeners('sf_image_transform.changed_source'));

    $this->pluginConfiguration->initialize();

    $this->assertEquals($change_action + 1, count($dispatcher->getListeners('controller.change_action')));
    $this->assertEquals($changed_source + 1, count($dispatcher->getListeners('sf_image_transform.changed_source')));
  }

  public function testSetCacheKey()
  {
    $internalUri = 'sfImageTransformator/index?type=TestFile&format=original&path=00/00/00&slug=barfoo&id=1&sf_format=jpg';
    $viewCacheManager = new sfViewCacheManager(sfContext::getInstance(), new sfNoCache());
    $path = sfImageTransformExtraPluginConfiguration::setCacheKey($internalUri, '', '', '', $viewCacheManager);
    $this->assertContains('/thumbnails/TestFile/original/00/00/00/barfoo-1.jpg', $path);
  }

  public function testSetViewCache()
  {
    $this->markTestSkipped('ViewCacheManagers can not be tested from command line');
  }

  public function testGetCache()
  {
    $this->assertType('sfRawFileCache', sfImageTransformExtraPluginConfiguration::getCache());
  }

  public function testRemoveOldThumbnails()
  {
    //$event = new sfEvent($this, 'sf_image_transform.changed_source', array());
    //sfImageTransformExtraPluginConfiguration::registerStreamWrapper($event);
    $this->markTestIncomplete('Removal not yet implemented');
{'fraction_non_alphanumeric': 0.13214482631869143, 'fraction_numerical': 0.013416651350854623, 'mean_word_length': 5.794007490636704, 'pattern_counts': {'":': 0, '<': 23, '<?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': '3140108', 'n_tokens_mistral': 1576, 'n_tokens_neox': 1526, 'n_words': 288}