6 class CookieTest
extends \PHPUnit\Framework\TestCase
{
9 * @dataProvider cookieDomains
10 * @covers Cookie::validateCookieDomain
12 public function testValidateCookieDomain( $expected, $domain, $origin = null ) {
14 $ok = Cookie
::validateCookieDomain( $domain, $origin );
15 $msg = "$domain against origin $origin";
17 $ok = Cookie
::validateCookieDomain( $domain );
20 $this->assertEquals( $expected, $ok, $msg );
23 public static function cookieDomains() {
27 [ true, "wikipedia.org" ],
28 [ true, ".wikipedia.org" ],
33 [ true, "supermarket.uk" ],
36 [ false, "127.0.0." ],
38 [ false, "127.0.0.1." ],
39 [ true, "127.0.0.1" ],
40 [ false, "333.0.0.1" ],
41 [ true, "example.com" ],
42 [ false, "example.com." ],
43 [ true, ".example.com" ],
45 [ true, ".example.com", "www.example.com" ],
46 [ false, "example.com", "www.example.com" ],
47 [ true, "127.0.0.1", "127.0.0.1" ],
48 [ false, "127.0.0.1", "localhost" ],