/** * Sets the property as a DateTime object. * * @param \DateTime $dt * @return void */ public function setDateTime(\DateTime $dt) { $this->value = $dt->format('Ymd'); }
public function testUpdateShareLink() { $manager = $this->createManagerMock()->setMethods(['canShare', 'getShareById', 'generalCreateChecks', 'linkCreateChecks', 'pathCreateChecks', 'verifyPassword', 'validateExpirationDate'])->getMock(); $user = $this->getMock('\\OCP\\IUser'); $user->method('getUID')->willReturn('owner'); $originalShare = new \OC\Share20\Share(); $originalShare->setShareType(\OCP\Share::SHARE_TYPE_LINK); $tomorrow = new \DateTime(); $tomorrow->setTime(0, 0, 0); $tomorrow->add(new \DateInterval('P1D')); $file = $this->getMock('OCP\\Files\\File', [], [], 'File'); $file->method('getId')->willReturn(100); $share = $this->manager->newShare(); $share->setProviderId('foo')->setId('42')->setShareType(\OCP\Share::SHARE_TYPE_LINK)->setSharedBy($user)->setShareOwner($user)->setPassword('password')->setExpirationDate($tomorrow)->setNode($file); $manager->expects($this->once())->method('canShare')->willReturn(true); $manager->expects($this->once())->method('getShareById')->with('foo:42')->willReturn($originalShare); $manager->expects($this->once())->method('validateExpirationDate')->with($share); $this->defaultProvider->expects($this->once())->method('update')->with($share)->willReturn($share); $hookListner = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); \OCP\Util::connectHook('OCP\\Share', 'post_set_expiration_date', $hookListner, 'post'); $hookListner->expects($this->once())->method('post')->with(['itemType' => 'file', 'itemSource' => 100, 'date' => $tomorrow, 'uidOwner' => 'owner']); $manager->updateShare($share); }
public function testGetDateIncompleteFromVCard() { $vcard = <<<VCF BEGIN:VCARD VERSION:4.0 BDAY:--0407 END:VCARD VCF; $vcard = Reader::read($vcard); $prop = $vcard->BDAY; $dt = $prop->getDateTime(); // Note: if the year changes between the last line and the next line of // code, this test may fail. // // If that happens, head outside and have a drink. $current = new \DateTime('now'); $year = $current->format('Y'); $this->assertEquals($year . '0407', $dt->format('Ymd')); }