Altax\Module\Server\Resource\Node::setKey PHP 메소드

setKey() 공개 메소드

public setKey ( $key )
    public function setKey($key)
    {
        $this->key = $key;
    }

Usage Example

예제 #1
0
 public function testReplaceTilda()
 {
     $node = new Node();
     Env::set("homedir", "/home/your");
     $node->setKey("~/path/to/private_key");
     $this->assertEquals("~/path/to/private_key", $node->getKey());
     $this->assertEquals("/home/your/path/to/private_key", $node->getKeyOrDefault());
     $node->setKey("~user/path/to/private_key");
     $this->assertEquals("~user/path/to/private_key", $node->getKey());
     $this->assertEquals("~user/path/to/private_key", $node->getKeyOrDefault());
     $node->setKey("~");
     $this->assertEquals("~", $node->getKey());
     $this->assertEquals("/home/your", $node->getKeyOrDefault());
     Env::set("homedir", "/home/your\\0");
     $node->setKey("~/path/to/private_key");
     $this->assertEquals("~/path/to/private_key", $node->getKey());
     $this->assertEquals("/home/your\\0/path/to/private_key", $node->getKeyOrDefault());
     $node->setKey("/path/to/private_key~");
     $this->assertEquals("/path/to/private_key~", $node->getKey());
     $this->assertEquals("/path/to/private_key~", $node->getKeyOrDefault());
 }