server->getIfConditions($request); $this->assertEquals([], $conditions); } function testLockToken() { $request = new HTTP\Request('GET', '/path/', ['If' => '()']); $conditions = $this->server->getIfConditions($request); $compare = [ [ 'uri' => 'path', 'tokens' => [ [ 'negate' => false, 'token' => 'opaquelocktoken:token1', 'etag' => '', ], ], ], ]; $this->assertEquals($compare, $conditions); } function testNotLockToken() { $serverVars = [ 'HTTP_IF' => '(Not )', 'REQUEST_URI' => '/bla' ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $conditions = $this->server->getIfConditions($request); $compare = [ [ 'uri' => 'bla', 'tokens' => [ [ 'negate' => true, 'token' => 'opaquelocktoken:token1', 'etag' => '', ], ], ], ]; $this->assertEquals($compare, $conditions); } function testLockTokenUrl() { $serverVars = [ 'HTTP_IF' => ' ()', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $conditions = $this->server->getIfConditions($request); $compare = [ [ 'uri' => '', 'tokens' => [ [ 'negate' => false, 'token' => 'opaquelocktoken:token1', 'etag' => '', ], ], ], ]; $this->assertEquals($compare, $conditions); } function test2LockTokens() { $serverVars = [ 'HTTP_IF' => '() (Not )', 'REQUEST_URI' => '/bla', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $conditions = $this->server->getIfConditions($request); $compare = [ [ 'uri' => 'bla', 'tokens' => [ [ 'negate' => false, 'token' => 'opaquelocktoken:token1', 'etag' => '', ], [ 'negate' => true, 'token' => 'opaquelocktoken:token2', 'etag' => '', ], ], ], ]; $this->assertEquals($compare, $conditions); } function test2UriLockTokens() { $serverVars = [ 'HTTP_IF' => ' () (Not )', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $conditions = $this->server->getIfConditions($request); $compare = [ [ 'uri' => 'node1', 'tokens' => [ [ 'negate' => false, 'token' => 'opaquelocktoken:token1', 'etag' => '', ], ], ], [ 'uri' => 'node2', 'tokens' => [ [ 'negate' => true, 'token' => 'opaquelocktoken:token2', 'etag' => '', ], ], ], ]; $this->assertEquals($compare, $conditions); } function test2UriMultiLockTokens() { $serverVars = [ 'HTTP_IF' => ' () () (Not )', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $conditions = $this->server->getIfConditions($request); $compare = [ [ 'uri' => 'node1', 'tokens' => [ [ 'negate' => false, 'token' => 'opaquelocktoken:token1', 'etag' => '', ], [ 'negate' => false, 'token' => 'opaquelocktoken:token2', 'etag' => '', ], ], ], [ 'uri' => 'node2', 'tokens' => [ [ 'negate' => true, 'token' => 'opaquelocktoken:token3', 'etag' => '', ], ], ], ]; $this->assertEquals($compare, $conditions); } function testEtag() { $serverVars = [ 'HTTP_IF' => '(["etag1"])', 'REQUEST_URI' => '/foo', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $conditions = $this->server->getIfConditions($request); $compare = [ [ 'uri' => 'foo', 'tokens' => [ [ 'negate' => false, 'token' => '', 'etag' => '"etag1"', ], ], ], ]; $this->assertEquals($compare, $conditions); } function test2Etags() { $serverVars = [ 'HTTP_IF' => ' (["etag1"]) (["etag2"])', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $conditions = $this->server->getIfConditions($request); $compare = [ [ 'uri' => '', 'tokens' => [ [ 'negate' => false, 'token' => '', 'etag' => '"etag1"', ], [ 'negate' => false, 'token' => '', 'etag' => '"etag2"', ], ], ], ]; $this->assertEquals($compare, $conditions); } function testComplexIf() { $serverVars = [ 'HTTP_IF' => ' ( ["etag1"]) ' . '(Not ) (["etag2"]) ' . '() (Not ) (["etag3"])', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $conditions = $this->server->getIfConditions($request); $compare = [ [ 'uri' => 'node1', 'tokens' => [ [ 'negate' => false, 'token' => 'opaquelocktoken:token1', 'etag' => '"etag1"', ], [ 'negate' => true, 'token' => 'opaquelocktoken:token2', 'etag' => '', ], [ 'negate' => false, 'token' => '', 'etag' => '"etag2"', ], ], ], [ 'uri' => 'node2', 'tokens' => [ [ 'negate' => false, 'token' => 'opaquelocktoken:token3', 'etag' => '', ], [ 'negate' => true, 'token' => 'opaquelocktoken:token4', 'etag' => '', ], [ 'negate' => false, 'token' => '', 'etag' => '"etag3"', ], ], ], ]; $this->assertEquals($compare, $conditions); } }