mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 17:58:41 +00:00
test fixes
This commit is contained in:
parent
4a3410d182
commit
6e52397ab4
|
|
@ -151,11 +151,11 @@ interface ContainerInterface
|
|||
/**
|
||||
* Get the owner id of the resource.
|
||||
*
|
||||
* @return int
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getOwner() : int;
|
||||
public function getOwner() : string;
|
||||
|
||||
/**
|
||||
* Get the permissions id of the resource.
|
||||
|
|
|
|||
|
|
@ -66,7 +66,10 @@ class Directory extends FileAbstract implements DirectoryInterface
|
|||
return null;
|
||||
}
|
||||
|
||||
\ftp_login($con, $http->user, $http->pass);
|
||||
$status = \ftp_login($con, $http->user, $http->pass);
|
||||
if ($status === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($http->getPath() !== '') {
|
||||
@\ftp_chdir($con, $http->getPath());
|
||||
|
|
@ -347,6 +350,16 @@ class Directory extends FileAbstract implements DirectoryInterface
|
|||
return self::parseRawList($con, self::parent($path))[$path]['user'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getOwner() : string
|
||||
{
|
||||
$this->owner = self::parseRawList($this->con, self::parent($this->path))[$this->path]['user'];
|
||||
|
||||
return $this->owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get detailed file/dir list.
|
||||
*
|
||||
|
|
@ -407,6 +420,16 @@ class Directory extends FileAbstract implements DirectoryInterface
|
|||
return self::parseRawList($con, self::parent($path))[$path]['permission'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getPermission() : int
|
||||
{
|
||||
$this->permission = self::parseRawList($this->con, self::parent($this->path))[$this->path]['permission'];
|
||||
|
||||
return $this->permission;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -86,7 +86,10 @@ class File extends FileAbstract implements FileInterface
|
|||
return null;
|
||||
}
|
||||
|
||||
\ftp_login($con, $http->user, $http->pass);
|
||||
$status = \ftp_login($con, $http->user, $http->pass);
|
||||
if ($status === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($http->getPath() !== '') {
|
||||
@\ftp_chdir($con, $http->getPath());
|
||||
|
|
@ -294,6 +297,16 @@ class File extends FileAbstract implements FileInterface
|
|||
return Directory::parseRawList($con, self::dirpath($path))[$path]['user'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getOwner() : string
|
||||
{
|
||||
$this->owner = Directory::parseRawList($this->con, self::dirpath($this->path))[$this->path]['user'];
|
||||
|
||||
return $this->owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
@ -306,6 +319,16 @@ class File extends FileAbstract implements FileInterface
|
|||
return Directory::parseRawList($con, self::dirpath($path))[$path]['permission'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getPermission() : int
|
||||
{
|
||||
$this->permission = Directory::parseRawList($this->con, self::dirpath($this->path))[$this->path]['permission'];
|
||||
|
||||
return $this->permission;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the directory name of a file.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -95,10 +95,10 @@ abstract class FileAbstract implements FtpContainerInterface
|
|||
/**
|
||||
* Owner.
|
||||
*
|
||||
* @var int
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected int $owner = 0;
|
||||
protected string $owner = '';
|
||||
|
||||
/**
|
||||
* Permission.
|
||||
|
|
@ -191,7 +191,7 @@ abstract class FileAbstract implements FtpContainerInterface
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getOwner() : int
|
||||
public function getOwner() : string
|
||||
{
|
||||
return $this->owner;
|
||||
}
|
||||
|
|
@ -219,7 +219,7 @@ abstract class FileAbstract implements FtpContainerInterface
|
|||
$this->createdAt = (new \DateTimeImmutable())->setTimestamp($mtime === false ? 0 : $mtime);
|
||||
$this->changedAt->setTimestamp($ctime === false ? 0 : $ctime);
|
||||
|
||||
$this->owner = 0;
|
||||
$this->owner = '';
|
||||
$this->permission = 0;
|
||||
|
||||
$this->isInitialized = true;
|
||||
|
|
|
|||
|
|
@ -79,10 +79,10 @@ abstract class FileAbstract implements LocalContainerInterface
|
|||
/**
|
||||
* Owner.
|
||||
*
|
||||
* @var int
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected int $owner = 0;
|
||||
protected string $owner = '';
|
||||
|
||||
/**
|
||||
* Permission.
|
||||
|
|
@ -220,7 +220,7 @@ abstract class FileAbstract implements LocalContainerInterface
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getOwner() : int
|
||||
public function getOwner() : string
|
||||
{
|
||||
return $this->owner;
|
||||
}
|
||||
|
|
@ -246,7 +246,7 @@ abstract class FileAbstract implements LocalContainerInterface
|
|||
|
||||
$owner = \fileowner($this->path);
|
||||
|
||||
$this->owner = $owner === false ? 0 : $owner;
|
||||
$this->owner = $owner === false ? '' : (string) $owner;
|
||||
$this->permission = (int) \substr(\sprintf('%o', \fileperms($this->path)), -4);
|
||||
|
||||
$this->isInitialized = true;
|
||||
|
|
|
|||
|
|
@ -277,22 +277,25 @@ abstract class ViewAbstract implements RenderableInterface
|
|||
*/
|
||||
protected function renderTemplate(string $template, mixed ...$data) : string
|
||||
{
|
||||
$ob = '';
|
||||
$obLevel = 0;
|
||||
$ob = '';
|
||||
|
||||
try {
|
||||
if ($this->isBuffered) {
|
||||
\ob_start();
|
||||
}
|
||||
|
||||
$path = $template;
|
||||
if (!\is_file($path)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($this->isBuffered) {
|
||||
++$obLevel;
|
||||
\ob_start();
|
||||
}
|
||||
|
||||
/** @noinspection PhpIncludeInspection */
|
||||
$includeData = include $path;
|
||||
|
||||
if ($this->isBuffered) {
|
||||
--$obLevel;
|
||||
$ob = (string) \ob_get_clean();
|
||||
}
|
||||
|
||||
|
|
@ -300,7 +303,7 @@ abstract class ViewAbstract implements RenderableInterface
|
|||
$ob = (string) \json_encode($includeData);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
if ($this->isBuffered) {
|
||||
if ($obLevel > 0 && $this->isBuffered) {
|
||||
$ob .= (string) \ob_get_clean();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ final class FileTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testInvalidConnection() : void
|
||||
{
|
||||
self::assertFalse(File::ftpConnect(new HttpUri('ftp://karaka.app:21')));
|
||||
self::assertEquals(null, File::ftpConnect(new HttpUri('ftp://karaka.app:21')));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user