/** * Returns inner path * * @param string $path * @return string */ public static function getInnerPath($path) { Expect::that($path)->isString(); $sha1 = sha1($path); $md5 = md5($path); $lastDotPosition = strrpos($path, "."); $ext = $lastDotPosition === false ? "" : substr($path, $lastDotPosition); if (!preg_match('/^\\.[a-zA-Z0-9]+$/', $ext) || basename($path) == $ext) { $ext = ""; } $dirs = str_split($sha1, 2); $sha1Prefix = array_pop($dirs); $fileName = "{$sha1Prefix}-{$md5}{$ext}"; $innerPath = ""; foreach ($dirs as $dir) { $innerPath = "{$innerPath}/{$dir}"; } $innerPath = "{$innerPath}/{$fileName}"; return $innerPath; }
/** * @Given /^(?:|I )click "([^"]*)" in the email received(?:| at (\S*))$/ */ public function clickInTheEmail($link, $email = null) { Expect::that($this->connection)->isNotNull(); $account = $this->accountForEmail($email); $message = $this->getNewMessage($account); $message = $account->fetch_email($message['mail_id']); $dom = new DomDocument(); $dom->loadHTML($message['mail_body']); $xpath = new DomXPath($dom); $link = $this->getSession()->getSelectorsHandler()->xpathLiteral($link); $list = $xpath->query($this->getSession()->getSelectorsHandler()->getSelector("named")->translateToXPath(array("link_or_button", $link))); if (!$list->length) { $list = $xpath->query($this->getSession()->getSelectorsHandler()->getSelector("named")->translateToXPath(array("link_or_button_parent", $link))); } Expect::that($list->length)->isGreaterThan(0); $link = $list->item($list->length - 1)->getAttribute('href'); $this->getSession()->visit($link); }
/** * @inheritdoc */ public function getMetadataFromIndex($directory, $recursive) { Expect::that($directory)->isString(); Expect::that($directory)->isNotEmpty(); if ($directory == "/" && $recursive) { return iterator_to_array($this->getMetadataFromIndexBackward($directory, $recursive)); } else { return iterator_to_array($this->getMetadataFromIndexForward($directory, $recursive)); } }
/** * @inheritdoc */ public function setFilesystem(FilesystemInterface $fileSystem) { Expect::that($fileSystem)->isInstanceOf(FileSystem::class); $this->fileSystem = $fileSystem; }
/** * @param FilesystemInterface $outerFileSystem * @param string $pathToDatabase */ public static function register(FilesystemInterface $outerFileSystem, $pathToDatabase) { Expect::that($pathToDatabase)->isString(); parent::register($outerFileSystem, $pathToDatabase); }