function testGetRulesFromIni()
  {
    $cache_manager = new FullPageCacheManager();

    registerTestingIni(
      '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->getRules(),
      array(
        array('path_regex' => '/root/test1', 'optional' => array('test1', 'test2')),
        array('path_regex' => '/root/test2', 'groups' => array('members', 'visitors'))
      )
    );

    clearTestingIni();
  }
  function testGetPackagesFromIni()
  {
    registerTestingIni(
      'packages.ini',
      '
       packages[] = {PACKAGES_DIR_FOR_PACKAGES_INFO_TEST}test1
       packages[] = {PACKAGES_DIR_FOR_PACKAGES_INFO_TEST}test2
      '
    );

    $this->assertEqual($this->info->getPackages(),
      array(
        array('path' => PACKAGES_DIR_FOR_PACKAGES_INFO_TEST . 'test1',
              'name' => 'PACKAGE1_FOR_PACKAGES_INFO_TEST'),
        array('path' => PACKAGES_DIR_FOR_PACKAGES_INFO_TEST . 'test2',
              'name' => 'PACKAGE2_FOR_PACKAGES_INFO_TEST')
      )
    );

    $this->assertTrue(defined('PACKAGE1_FOR_PACKAGES_INFO_TEST_DIR'));
    $this->assertTrue(defined('PACKAGE2_FOR_PACKAGES_INFO_TEST_DIR'));
    $this->assertEqual(constant('PACKAGE1_FOR_PACKAGES_INFO_TEST_DIR'), PACKAGES_DIR_FOR_PACKAGES_INFO_TEST . 'test1');
    $this->assertEqual(constant('PACKAGE2_FOR_PACKAGES_INFO_TEST_DIR'), PACKAGES_DIR_FOR_PACKAGES_INFO_TEST . 'test2');

    clearTestingIni();
  }
  function testGetRulesFromIni()
  {
    $cache_manager = new PartialPageCacheManager();

    registerTestingIni(
      '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->getRules(),
      array(
        array('server_id' => 'test1', 'optional' => array('test1'), 'required' => array('test2')),
        array('server_id' => 'wow', 'groups' => array('members', 'visitors'))
      )
    );

    clearTestingIni();
  }
  function testGetConfig()
  {
    registerTestingIni('test-config.ini', 'test = 1');

    $conf = $this->toolkit->getINI('test-config.ini');
    $this->assertEqual($conf->getOption('test'), 1);
  }
 function setUp()
 {
     registerTestingIni('acl.ini', '
   users[] = vasa:0ef9e88d20d59114a89dad73c2bc0625:Vasa Pupkin:test@example.com:visitors
   users[] = admin:0ef9e88d20d59114a89dad73c2bc0625:Super Admin:admin@test.com:admins
     ');
     $this->dao = new SimpleACLIniBasedUsersDAO();
 }
 function testLoginSuccess()
 {
     registerTestingIni('acl.ini', 'users[] = test:' . md5($password = '******') . ':bill:test@dot.com:test');
     $toolkit =& Limb::toolkit();
     $ds =& $toolkit->getDataspace();
     $ds->set('password', $password);
     $ds->set('login', 'test');
     $this->assertEqual($this->cmd->perform(), LIMB_STATUS_OK);
 }
 function testLoadPolicyFailedNoOptions()
 {
     registerTestingIni('acl.ini', '
   user[] = some user data
   ');
     $authorizer = new MockSimpleACLAuthorizer($this);
     $authorizer->expectNever('attachPolicy');
     $this->loader->load($authorizer);
     $authorizer->tally();
     clearTestingIni();
 }
  function setUp()
  {
    parent :: setUp();

    registerTestingIni(
      'common.ini',
      '
      [Templates]
       path = ' . OVERRIDE_TEMPLATE_DIR_FOR_TEST . '
      '
    );
  }
  function setUp()
  {
    parent :: setUp();

    registerTestingIni(
      'common.ini',
      '
      [Templates]
       templates_path = ' . OVERRIDE_TEMPLATE_DIR_FOR_TEST . '
       shared_templates_path = ' . LIMB_DIR . '/design/
      '
    );
  }
 function setUp()
 {
     $this->authorizer = new SimpleACLAuthorizer();
     registerTestingIni('SimpleACLAuthorizerTestService.service.ini', '
   [read]
   access = 1
   [edit]
   access = 2
   [create]
   access = 4
   [delete]
   access = 128
   ');
 }
  function setUp()
  {
    Limb :: toolkit()->flushINICache();
    PackagesInfo :: instance()->reset();

    DebugMock :: init($this);

    $this->resolver =& $this->_defineResolver();

    registerTestingIni(
      'packages.ini',
      '
       packages[] = {TEST_PACKAGES_RESOLVER_DIR}package2/1.0/
       packages[] = {TEST_PACKAGES_RESOLVER_DIR}package3/1.1/
      '
    );
  }
  function testGetRequestedServiceOkNotExactMatch()
  {
    registerTestingIni('services.ini',
                       '
                       [AnyService]
                       path = /news*
                       service_name = NewsService
                       ');

    $toolkit =& Limb :: toolkit();
    $request = $toolkit->getRequest();
    $resolver = new IniBasedServiceRequestResolver();
    $uri =& $request->getUri();
    $uri->setPath('/news/10/10');

    $service = $resolver->resolve($request);

    $this->assertEqual($service->getName(), 'NewsService');
  }
Пример #13
0
  function testDontCache()
  {
    registerTestingIni(
      'testing.ini',
      'test = 1'
    );

    $ini = new IniMockVersion($this);

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

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

    $ini->tally();
  }
  function testGetRulesFromIni()
  {
    $cache_manager = new ImageCacheManager();

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

    $this->toolkit->setReturnValue('getINI',
                                   getIni('image_cache.ini'),
                                   array('image_cache.ini'));

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

    clearTestingIni();
  }
  function testRunOkActionNotFound()
  {
    registerTestingIni('404.service.ini',
                       'default_action = display
                       [display]');

    $toolkit =& Limb :: toolkit();

    $request =& $toolkit->getRequest();
    $response = $toolkit->getResponse();

    $this->fc->expectOnce('next');

    $this->service_resolver->expectOnce('resolve', array($request));
    $this->service_resolver->setReturnReference('resolve', $this->service);

    $this->action_resolver->expectOnce('resolve', array($request));
    $this->action_resolver->setReturnValue('resolve', $action = 'do');

    $this->service->expectOnce('actionExists', array($action));
    $this->service->setReturnValue('actionExists', false);

    $filter = new ServiceActionMappingFilter();

    $filter->run($this->fc, $request, $response);
    $service404 = $toolkit->getService();
    $this->assertEqual($service404->getName(), '404');
    $this->assertEqual($service404->getCurrentAction(), 'display');

    clearTestingIni();
  }
  function testRealPerform()
  {
    $handle = dirname(__FILE__) . '/TestingCronJob';
    registerTestingIni(
      'cron.ini',
      "
      [cron-job1]
       handle = {$handle}
      "
    );

    $cron_manager = new CronManager();

    $this->response->expectArgumentsAt(1, 'write', array('I was performed'));

    $cron_manager->perform($this->response);

    $contents = $this->_readJobsLastTime();

    $this->assertWantedPattern("/^cron-job1 = \d+$/", $contents);
  }
  function testCacheHit()
  {
    registerTestingIni(
      'testing2.ini',
      'test = 1'
    );

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

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

    $ini_mock = new IniMockVersionOverride($this);

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

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

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

    $ini_mock->tally();

    $ini->resetCache();
  }
  function testGetDefaultAction()
  {
    registerTestingIni(
      'test.service.ini',
      '
      default_action = admin_display

      [admin_display]
      some_properties
      '
    );

    $service = new Service('test');
    $this->assertTrue($service->getDefaultAction(), 'admin_display');
  }