Example #1
0
    public function testFrom()
    {
        $curlCookie = '# Netscape HTTP Cookie File
# http://curl.haxx.se/rfc/cookie_spec.html
# This file was generated by libcurl! Edit at your own risk.

#HttpOnly_.test1.ru	TRUE	/	FALSE	0	PHPSESSID	57f1bcb516082cbdbc1929331e0e7312
.test1.ru	TRUE	/	FALSE	1416569958	BITRIX_SM_GUEST_ID	87997
.test1.ru	TRUE	/	FALSE	1416569958	BITRIX_SM_LAST_VISIT	26.11.2013+15%3A39%3A18
.test1.ru	TRUE	/	FALSE	1416569702	BITRIX_SM_SALE_UID	753959';
        $testCookie = CurlCookie::from($curlCookie);
        $this->assertTrue(is_array($testCookie));
        $this->assertArrayHasKey('BITRIX_SM_GUEST_ID', $testCookie);
        $this->assertArrayHasKey('value', $testCookie['BITRIX_SM_GUEST_ID']);
        $this->assertEquals('87997', $testCookie['BITRIX_SM_GUEST_ID']['value']);
        $this->assertArrayHasKey('PHPSESSID', $testCookie);
        $this->assertArrayHasKey('value', $testCookie['PHPSESSID']);
        $this->assertEquals('57f1bcb516082cbdbc1929331e0e7312', $testCookie['PHPSESSID']['value']);
        $this->assertArrayHasKey('httponly', $testCookie['PHPSESSID']);
        $this->assertEquals(true, $testCookie['PHPSESSID']['httponly']);
    }