/** * Testing the checkIfAccessingFromSecureURL method with good and bad input. * * @since 1.2.1 */ public function testCheckIfAccessingFromSecureURL() { $config = ConfigProvider::getInstance(); $controller = new ImageController(); $_GET['tk'] = null; $_SERVER['REQUEST_URI'] = '/search'; $request = new Request(array('method' => 'GET')); $controller->setRequest($request); $this->assertFalse($controller->checkIfAccessingFromSecureURL(), 'Testing that the false is returned when tk is unavailable'); $_GET['tk'] = '8kqoeebEej0V-FN5-DOdA1HBDDieFcNWTib2yLSUNjq0B0FWzAupIA=='; $request = new Request(array('method' => 'GET')); $controller->setRequest($request); $this->assertTrue($controller->checkIfAccessingFromSecureURL(), 'Testing that the true is returned when tk is set in global _GET array'); $_GET['tk'] = null; $_SERVER['REQUEST_URI'] = $config->get('app.url') . '/tk/8kqoeebEej0V-FN5-DOdA1HBDDieFcNWTib2yLSUNjq0B0FWzAupIA=='; $request = new Request(array('method' => 'GET')); $controller->setRequest($request); $this->assertTrue($controller->checkIfAccessingFromSecureURL(), 'Testing that the true is returned when tk is part of the mod_rewrite style URL'); }