function test_get_rules_from_ini()
  {
    $cache_manager = new full_page_cache_manager();

    register_testing_ini(
      'full_page_cache.ini',
      '
      [rule1]
       path_regex = /root/test1
       optional[] = test1
       optional[] = test2
      [rule2]
       path_regex = /root/test2
       groups[] = members
       groups[] = visitors
      [not_valid_rule]
       path_regex = /root/test3
      '
    );

    $this->assertEqual($cache_manager->get_rules(),
      array(
        array('path_regex' => '/root/test1', 'optional' => array('test1', 'test2')),
        array('path_regex' => '/root/test2', 'groups' => array('members', 'visitors'))
      )
    );

    clear_testing_ini();
  }
  function test_get_rules_from_ini()
  {
    $cache_manager = new partial_page_cache_manager();

    register_testing_ini(
      'partial_page_cache.ini',
      '
      [rule1]
       server_id = test1
       optional[] = test1
       required[] = test2
      [rule2]
       server_id = wow
       groups[] = members
       groups[] = visitors
      [not_valid_rule]
       bla-bla = bla-bla
      '
    );

    $this->assertEqual($cache_manager->get_rules(),
      array(
        array('server_id' => 'test1', 'optional' => array('test1'), 'required' => array('test2')),
        array('server_id' => 'wow', 'groups' => array('members', 'visitors'))
      )
    );

    clear_testing_ini();
  }
 function test_get_dataset()
 {
     register_testing_ini('referers_groups.ini', 'groups[] = group1
                       groups[] = group2
                      ');
     $this->report->expectOnce('fetch_count_except_groups', array(array('group1', 'group2')));
     $this->report->setReturnValue('fetch_count_except_groups', 3);
     $this->report->expectOnce('fetch_except_groups', array(array('group1', 'group2'), $limit = 0, $offset = 0));
     $this->report->setReturnValue('fetch_except_groups', array(array('hits' => 5), array('hits' => 15), array('hits' => 11)));
     $this->report->expectOnce('fetch_total_hits');
     $this->report->setReturnValue('fetch_total_hits', 1000);
     $this->assertEqual($this->ds->get_dataset($counter, array()), new array_dataset(array(array('hits' => 5, 'percentage' => '0.5'), array('hits' => 15, 'percentage' => '1.5'), array('hits' => 11, 'percentage' => '1.1'))));
     $this->assertEqual($counter, 3);
 }
 function test_real_perform()
 {
     $handle = dirname(__FILE__) . '/testing_cron_job';
     register_testing_ini('cron.ini', " \r\n      [cron-job1]\r\n       handle = {$handle}\r\n      ");
     $cron_manager =& new cron_manager();
     $this->response->expectArgumentsAt(1, 'write', array('I was performed'));
     $cron_manager->perform($this->response);
     $contents = $this->_read_jobs_last_time();
     $this->assertWantedPattern("/^cron-job1 = \\d+\$/", $contents);
 }
Exemplo n.º 5
0
  function test_dont_cache()
  {
    register_testing_ini(
      'testing.ini',
      'test = 1'
    );

    $ini =& new ini_mock_version($this);

    $ini->expectOnce('_parse');
    $ini->expectNever('_save_cache');

    $ini->ini(VAR_DIR . 'testing.ini', false);

    $ini->tally();
  }
  function testCacheHit()
  {
    register_testing_ini(
      'testing2.ini',
      'test = 1'
    );

    register_testing_ini(
      'testing2.override.ini',
      'test = 2'
    );

    $ini = new ini(VAR_DIR . 'testing2.ini', true); //ini should be cached here...

    $ini_mock = new IniMockVersionOverride($this);

    touch($ini->get_cache_file(), time()+100);

    $ini_mock->expectNever('_parse');
    $ini_mock->expectNever('_save_cache');

    $ini_mock->ini(VAR_DIR . 'testing2.ini', true);

    $ini_mock->tally();

    $ini->reset_cache();
  }