当前位置: 首页>>代码示例>>PHP>>正文


PHP StandardAutoloader::setFallbackAutoloader方法代码示例

本文整理汇总了PHP中Zend\Loader\StandardAutoloader::setFallbackAutoloader方法的典型用法代码示例。如果您正苦于以下问题:PHP StandardAutoloader::setFallbackAutoloader方法的具体用法?PHP StandardAutoloader::setFallbackAutoloader怎么用?PHP StandardAutoloader::setFallbackAutoloader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Loader\StandardAutoloader的用法示例。


在下文中一共展示了StandardAutoloader::setFallbackAutoloader方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 public function setUp()
 {
     if (!class_exists('Archive_Tar')) {
         $autoloader = new StandardAutoloader();
         $autoloader->setFallbackAutoloader(true);
         if (!$autoloader->autoload('Archive_Tar')) {
             $this->markTestSkipped('This filter needs PEARs Archive_Tar');
         }
     }
     $files = array(dirname(__DIR__) . '/_files/zipextracted.txt', dirname(__DIR__) . '/_files/_compress/Compress/First/Second/zipextracted.txt', dirname(__DIR__) . '/_files/_compress/Compress/First/Second', dirname(__DIR__) . '/_files/_compress/Compress/First/zipextracted.txt', dirname(__DIR__) . '/_files/_compress/Compress/First', dirname(__DIR__) . '/_files/_compress/Compress/zipextracted.txt', dirname(__DIR__) . '/_files/_compress/Compress', dirname(__DIR__) . '/_files/_compress/zipextracted.txt', dirname(__DIR__) . '/_files/_compress', dirname(__DIR__) . '/_files/compressed.tar');
     foreach ($files as $file) {
         if (file_exists($file)) {
             if (is_dir($file)) {
                 rmdir($file);
             } else {
                 unlink($file);
             }
         }
     }
     if (!file_exists(dirname(__DIR__) . '/_files/Compress/First/Second')) {
         mkdir(dirname(__DIR__) . '/_files/Compress/First/Second', 0777, true);
         file_put_contents(dirname(__DIR__) . '/_files/Compress/First/Second/zipextracted.txt', 'compress me');
         file_put_contents(dirname(__DIR__) . '/_files/Compress/First/zipextracted.txt', 'compress me');
         file_put_contents(dirname(__DIR__) . '/_files/Compress/zipextracted.txt', 'compress me');
     }
 }
开发者ID:bradley-holt,项目名称:zf2,代码行数:26,代码来源:TarTest.php

示例2: testReturnsFalseForInvalidClassNames

 public function testReturnsFalseForInvalidClassNames()
 {
     $loader = new StandardAutoloader();
     $loader->setFallbackAutoloader(true);
     $this->assertFalse($loader->autoload('Some\\Invalid\\Classname\\'));
 }
开发者ID:rajanlamic,项目名称:IntTest,代码行数:6,代码来源:StandardAutoloaderTest.php

示例3: testCanActAsFallbackAutoloader

 public function testCanActAsFallbackAutoloader()
 {
     $loader = new StandardAutoloader();
     $loader->setFallbackAutoloader(true);
     set_include_path(__DIR__ . '/TestAsset/' . PATH_SEPARATOR . $this->includePath);
     $loader->autoload('TestNamespace\\FallbackCase');
     $this->assertTrue(class_exists('TestNamespace\\FallbackCase', false));
 }
开发者ID:rexmac,项目名称:zf2,代码行数:8,代码来源:StandardAutoloaderTest.php

示例4: testCanActAsFallbackAutoloader

    /**
     * borrowed from Zend\Loader\StandardAutoloader
     */
    public function testCanActAsFallbackAutoloader()
    {
        $loader = new StandardAutoloader();
        $loader->setFallbackAutoloader(true);
        set_include_path(__DIR__ . '/TestAsset/' . PATH_SEPARATOR . $this->includePath);
        $loader->autoload('TestNamespace\TestProvider');
        $loader->autoload('TestNamespace\TestInvalidProvider');

        //initialize ini
        $ini = __DIR__. '/_files/enable.ini';
        file_put_contents($ini, '');

        $clientConfig = new ClientConfig;
        $clientConfig->setConfigFilePath($ini);
        $this->_registry->setConfig($clientConfig);
        $config = $this->_configProvider;

        // Test enable provider 
        try {
            $config->enableProvider('TestNamespace\TestInvalidProvider');
            $this->fail('RuntimeException was expected but not thrown');
        } catch (RuntimeException $re) {
        }

        $config->enableProvider('TestNamespace\TestProvider');
        $configs = $clientConfig->basicloader->classes;
        $this->assertEquals('TestNamespace\TestProvider', $configs->current());
        
        // Test disable provider
        try {
            $config->disableProvider('TestNamespace\TestInvalidProvider');
            $this->fail('RuntimeException was expected but not thrown');
        } catch (RuntimeException $re) {
        }

        $config->disableProvider('TestNamespace\TestProvider');
        $this->assertEmpty($configs->current(), 'No config setting will exists');

        /**
         * manifest test
         */
        $loader->autoload('TestNamespace\TestManifest');
        $loader->autoload('TestNamespace\TestInvalidManifest');

        try {
            $config->enableManifest('TestNamespace\TestInvalidManifest');
            $this->fail('RuntimeException was expected but not thrown');
        } catch (RuntimeException $re) {
        }

        $config->enableManifest('TestNamespace\TestManifest');

        $configs = $clientConfig->basicloader->classes;
        $this->assertEquals('TestNamespace\TestManifest', $configs->current());

        try {
            $config->disableManifest('TestNamespace\TestInvalidManifest');
            $this->fail('RuntimeException was expected but not thrown');
        } catch (RuntimeException $re) {
        }

        $config->disableManifest('TestNamespace\TestManifest');
        $this->assertEmpty($configs->current(), 'No config setting will exists');

        // cleanup
        file_put_contents($ini, '');
    }
开发者ID:ruflin,项目名称:zf2,代码行数:70,代码来源:ConfigTest.php

示例5: testCanActAsFallbackAutoloader

    /**
     * borrowed from Zend\Loader\StandardAutoloader
     */
    public function testCanActAsFallbackAutoloader()
    {
        $loader = new StandardAutoloader();
        $loader->setFallbackAutoloader(true);
        set_include_path(__DIR__ . '/TestAsset/' . PATH_SEPARATOR . $this->includePath);
        $loader->autoload('TestNamespace\TestProvider');
        $loader->autoload('TestNamespace\TestInvalidProvider');

        //initialize ini
        $ini = __DIR__. '/_files/enable.ini';
        file_put_contents($ini, '');

        $clientConfig = new ClientConfig;
        $clientConfig->setConfigFilePath($ini);
        $this->_registry->setConfig($clientConfig);
        $config = $this->_configProvider;

        try {
            $config->enableProvider('TestNamespace\TestInvalidProvider');
            $this->fail('RuntimeException was expected but not thrown');
        } catch (RuntimeException $re) {
        }

        $config->enableProvider('TestNamespace\TestProvider');
        $providers = $clientConfig->basicloader->classes->toArray();
        $this->assertEquals('TestNamespace\TestProvider', current($providers));
        
        file_put_contents($ini, '');
    }
开发者ID:niallmccrudden,项目名称:zf2,代码行数:32,代码来源:ConfigTest.php


注:本文中的Zend\Loader\StandardAutoloader::setFallbackAutoloader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。