/** * @test * @depends URI\ParseTest::Advanced_Parsing * @depends Simple_Replace * @depends Simple_Output * @depends Aliases * @depends URI\ErrorsTest::Parse_Errors * @depends URI\ErrorsTest::Invalid_Section_Errors */ public function Reset() { $uri1 = new \uri('example.com/original/path'); // Check For Errors $this->assertEmpty($uri1->error); // Check Replace $this->assertEquals('example.com/alternative/path', $uri1->replace('PATH', '/alternative/path')); $uri1->reset(); $this->assertEquals('example.com/original/path', $uri1->str()); }
/** * @test * @depends URI\ParseTest::Advanced_Parsing */ public function Invalid_Port() { $uri1 = new \uri('https://*****:*****@example.com:777/path/to/script.php?query=str#fragment'); // Invalid section to modify; $this->assertEquals(FALSE, $uri1->replace('PORT', 'invalid')); }
/** * @test * @depends URI\GenerateTest::Reset */ public function Modify_Fragment() { // Test both when there is and isn't pre-existing data $uri1 = new \uri('example.com'); $uri2 = new \uri('https://*****:*****@example.com:777/path/to/script.php?query=str#fragment'); // Check For Errors $this->assertEmpty($uri1->error); $this->assertEmpty($uri2->error); // Check Replace $this->assertEquals('example.com#top', $uri1->replace('FRAGMENT', '#top')); $this->assertEquals('example.com#header', $uri1->replace('FRAGMENT', 'header')); $this->assertEquals('https://*****:*****@example.com:777/path/to/script.php?query=str#footer', $uri2->replace('FRAGMENT', 'footer')); // Check Prepend $this->assertEquals('example.com#custom-header', $uri1->prepend('FRAGMENT', 'custom-')); // Check Append $this->assertEquals('https://*****:*****@example.com:777/path/to/script.php?query=str#footer-end', $uri2->append('FRAGMENT', '-end')); }