Exemplo n.º 1
0
 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');
     }
 }
Exemplo n.º 2
0
 public function testReturnsFalseForInvalidClassNames()
 {
     $loader = new StandardAutoloader();
     $loader->setFallbackAutoloader(true);
     $this->assertFalse($loader->autoload('Some\\Invalid\\Classname\\'));
 }
Exemplo n.º 3
0
 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));
 }
Exemplo n.º 4
0
    /**
     * 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, '');
    }
Exemplo n.º 5
0
    /**
     * 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, '');
    }