/** * Makes a list of non-SSLable servers. */ function _setNonSSLableServers() { $nonSSLableServers = $this->_getConfiguration('nonSSLableServers'); if (!is_array($nonSSLableServers)) { trigger_error('Failed to configure the configuration point [ nonSSLableServers ] at the plugin [ ' . __CLASS__ . ' ].', E_USER_WARNING); return; } foreach ($nonSSLableServers as $nonSSLableServer) { Piece_Unity_URL::addNonSSLableServer($nonSSLableServer); } }
function testNonSSLableServers() { $_SERVER['SERVER_NAME'] = 'example.org'; $_SERVER['SERVER_PORT'] = '80'; $config =& new Piece_Unity_Config(); $config->setConfiguration('KernelConfigurator', 'nonSSLableServers', array('example.org')); $context =& Piece_Unity_Context::singleton(); $context->setConfiguration($config); $configurator =& new Piece_Unity_Plugin_KernelConfigurator(); $configurator->invoke(); $this->assertEquals('http://example.org/foo/bar/baz.php', Piece_Unity_URL::createSSL('http://example.com/foo/bar/baz.php')); $this->assertEquals('http://example.org/foo/bar/baz.php', Piece_Unity_URL::createSSL('/foo/bar/baz.php')); $_SERVER['SERVER_PORT'] = '443'; $this->assertEquals('http://example.org/foo/bar/baz.php', Piece_Unity_URL::create('https://example.com/foo/bar/baz.php')); $this->assertEquals('http://example.org/foo/bar/baz.php', Piece_Unity_URL::create('/foo/bar/baz.php')); Piece_Unity_URL::clearNonSSLableServers(); unset($_SERVER['SERVER_PORT']); unset($_SERVER['SERVER_NAME']); }