本文整理汇总了PHP中OC\Share\Share::setPassword方法的典型用法代码示例。如果您正苦于以下问题:PHP Share::setPassword方法的具体用法?PHP Share::setPassword怎么用?PHP Share::setPassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC\Share\Share
的用法示例。
在下文中一共展示了Share::setPassword方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSetPasswordShareOtherUser
/**
* @expectedException \Exception
* @expectedExceptionMessage Cannot update share of a different user
*
* Test modification of share of another user
*/
public function testSetPasswordShareOtherUser()
{
$user = $this->getMockBuilder('\\OCP\\IUser')->disableOriginalConstructor()->getMock();
$user->method('getUID')->willReturn('user');
$userSession = $this->getMockBuilder('\\OCP\\IUserSession')->disableOriginalConstructor()->getMock();
$userSession->method('getUser')->willReturn($user);
$ex = $this->getMockBuilder('\\OC\\DB\\QueryBuilder\\ExpressionBuilder\\ExpressionBuilder')->disableOriginalConstructor()->getMock();
$qb = $this->getMockBuilder('\\OC\\DB\\QueryBuilder\\QueryBuilder')->disableOriginalConstructor()->getMock();
$qb->method('update')->will($this->returnSelf());
$qb->method('set')->will($this->returnSelf());
$qb->method('where')->will($this->returnSelf());
$qb->method('andWhere')->will($this->returnSelf());
$qb->method('select')->will($this->returnSelf());
$qb->method('from')->will($this->returnSelf());
$qb->method('setParameter')->will($this->returnSelf());
$qb->method('expr')->willReturn($ex);
$ret = $this->getMockBuilder('\\Doctrine\\DBAL\\Driver\\ResultStatement')->disableOriginalConstructor()->getMock();
$ret->method('fetch')->willReturn(['uid_owner' => 'user2']);
$qb->method('execute')->willReturn($ret);
$connection = $this->getMockBuilder('\\OC\\DB\\Connection')->disableOriginalConstructor()->getMock();
$connection->method('getQueryBuilder')->willReturn($qb);
$config = $this->getMockBuilder('\\OCP\\IConfig')->disableOriginalConstructor()->getMock();
\OC\Share\Share::setPassword($userSession, $connection, $config, 1, 'pass');
}
示例2: setPassword
/**
* Set expiration date for a share
* @param int $shareId
* @param string $password
* @return boolean
*/
public static function setPassword($shareId, $password)
{
$userSession = \OC::$server->getUserSession();
$connection = \OC::$server->getDatabaseConnection();
$config = \OC::$server->getConfig();
return \OC\Share\Share::setPassword($userSession, $connection, $config, $shareId, $password);
}