public function get(array $items) { include_once dirname(dirname(__FILE__)) . '/models/htaccess.php'; $htaccess = new Red_Htaccess(); foreach ($items as $item) { $htaccess->add($item); } return $htaccess->get(); }
public function testRedirectUrlWithQuery() { $htaccess = new Red_Htaccess(); $htaccess->add(new Red_Item((object) array('match_type' => 'url', 'id' => 1, 'action_type' => 'url', 'url' => '/my-test?query=1', 'action_code' => 301))); $htaccess->add(new Red_Item((object) array('match_type' => 'url', 'id' => 1, 'action_type' => 'url', 'url' => '/my-test.php?query=1&thing=2', 'action_code' => 302))); $file = $htaccess->get(); $lines = explode("\n", $file); $this->assertEquals('RewriteCond %{QUERY_STRING} ^query=1$', trim($lines[5])); $this->assertEquals('RewriteRule ^/my-test$ [R=301,L]', trim($lines[6])); $this->assertEquals('RewriteCond %{QUERY_STRING} ^query=1&thing=2$', trim($lines[7])); $this->assertEquals('RewriteRule ^/my-test\\.php$ [R=302,L]', trim($lines[8])); }