assertTrue($comparison->originsMatch()); } foreach ($bad as [$a, $b]) { $comparison = new UrlComparison($a, $b); $this->assertFalse($comparison->originsMatch()); } } public function test_paths_overlap() { $good = [ ['https://example.com', 'https://example.com/a/b/c'], ['https://example.com/', 'https://example.com/a/b/c'], ['https://example.com/a/b', 'https://example.com/a/b/c'], ['https://example.com/a/b/c', 'https://example.com/a'], ['http://donk.com/a/b/c?a=b#cat', 'https://example.com:5005/a/b#hello'], ]; $bad = [ ['https://example.com/a/c', 'https://example.com/a/b/c/d'], ['https://example.com/a/c', 'https://example.com/d/a/c'], ]; foreach ($good as [$a, $b]) { $comparison = new UrlComparison($a, $b); $this->assertTrue($comparison->pathsOverlap()); } foreach ($bad as [$a, $b]) { $comparison = new UrlComparison($a, $b); $this->assertFalse($comparison->pathsOverlap()); } } }