bug fixes with unit testing

This commit is contained in:
Dennis Eichhorn 2021-05-28 22:22:45 +02:00
parent 47767eea0d
commit 5b9315bf71
12 changed files with 71 additions and 22 deletions

View File

@ -98,13 +98,13 @@ final class ConsoleResponse extends ResponseAbstract implements RenderableInterf
/** /**
* Generate response based on header. * Generate response based on header.
* *
* @param bool $optimize Optimize response / minify * @param mixed $data Data passt to render function. (0 => bool: $optimize)
* *
* @return string * @return string
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function render(bool $optimize = false) : string public function render(...$data) : string
{ {
$types = $this->header->get('Content-Type'); $types = $this->header->get('Content-Type');
@ -114,7 +114,7 @@ final class ConsoleResponse extends ResponseAbstract implements RenderableInterf
} }
} }
return $this->getRaw($optimize); return $this->getRaw($data[0] ?? false);
} }
/** /**

View File

@ -100,7 +100,7 @@ final class HttpResponse extends ResponseAbstract implements RenderableInterface
/** /**
* Generate response based on header. * Generate response based on header.
* *
* @param mixed $data Data passt to render function. (0 => bool: $optimize * @param mixed $data Data passt to render function. (0 => bool: $optimize)
* *
* @return string * @return string
* *

View File

@ -84,13 +84,13 @@ final class SocketResponse extends ResponseAbstract implements RenderableInterfa
/** /**
* Generate response based on header. * Generate response based on header.
* *
* @param bool $optimize Optimize response / minify * @param mixed $data Data passt to render function. (0 => bool: $optimize)
* *
* @return string * @return string
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function render(bool $optimize = false) : string public function render(...$data) : string
{ {
$types = $this->header->get('Content-Type'); $types = $this->header->get('Content-Type');
@ -100,7 +100,7 @@ final class SocketResponse extends ResponseAbstract implements RenderableInterfa
} }
} }
return $this->getRaw($optimize); return $this->getRaw($data[0] ?? false);
} }
/** /**

View File

@ -53,8 +53,8 @@ class L11nManagerTest extends \PHPUnit\Framework\TestCase
self::assertFalse($this->l11nManager->isLanguageLoaded('en')); self::assertFalse($this->l11nManager->isLanguageLoaded('en'));
self::assertEquals([], $this->l11nManager->getModuleLanguage('en')); self::assertEquals([], $this->l11nManager->getModuleLanguage('en'));
self::assertEquals([], $this->l11nManager->getModuleLanguage('en', 'Admin')); self::assertEquals([], $this->l11nManager->getModuleLanguage('en', 'Admin'));
self::assertEquals('ERROR', $this->l11nManager->getHtml('en', 'Admin', 'Backend', 'Test2')); self::assertEquals('ERROR-Test2', $this->l11nManager->getHtml('en', 'Admin', 'Backend', 'Test2'));
self::assertEquals('ERROR', $this->l11nManager->getText('en', 'Admin', 'Backend', 'Test2')); self::assertEquals('ERROR-Test2', $this->l11nManager->getText('en', 'Admin', 'Backend', 'Test2'));
} }
/** /**

View File

@ -107,7 +107,7 @@ class SocketRouterTest extends \PHPUnit\Framework\TestCase
null, null,
null, null,
'TEST', 'TEST',
0, 'TEST',
1, 1,
null, null,
null, null,
@ -140,7 +140,7 @@ class SocketRouterTest extends \PHPUnit\Framework\TestCase
null, null,
null, null,
'TEST', 'TEST',
0, 'TEST',
1, 1,
null, null,
null, null,
@ -151,7 +151,7 @@ class SocketRouterTest extends \PHPUnit\Framework\TestCase
null, null,
null, null,
'InvalidModule', 'InvalidModule',
0, 'InvalidModule',
1, 1,
null, null,
null, null,
@ -162,7 +162,7 @@ class SocketRouterTest extends \PHPUnit\Framework\TestCase
null, null,
null, null,
'TEST', 'TEST',
0, 'TEST',
99, 99,
null, null,
null, null,

View File

@ -198,7 +198,7 @@ class WebRouterTest extends \PHPUnit\Framework\TestCase
null, null,
null, null,
'TEST', 'TEST',
0, 'TEST',
1, 1,
null, null,
null, null,
@ -238,7 +238,7 @@ class WebRouterTest extends \PHPUnit\Framework\TestCase
null, null,
null, null,
'TEST', 'TEST',
0, 'TEST',
1, 1,
null, null,
null, null,
@ -249,7 +249,7 @@ class WebRouterTest extends \PHPUnit\Framework\TestCase
null, null,
null, null,
'InvalidModule', 'InvalidModule',
0, 'InvalidModule',
1, 1,
null, null,
null, null,
@ -260,7 +260,7 @@ class WebRouterTest extends \PHPUnit\Framework\TestCase
null, null,
null, null,
'TEST', 'TEST',
0, 'TEST',
99, 99,
null, null,
null, null,

View File

@ -27,7 +27,7 @@ class AddressTypeTest extends \PHPUnit\Framework\TestCase
*/ */
public function testEnumCount() : void public function testEnumCount() : void
{ {
self::assertCount(7, AddressType::getconstants()); self::assertCount(8, AddressType::getconstants());
} }
/** /**
@ -52,5 +52,6 @@ class AddressTypeTest extends \PHPUnit\Framework\TestCase
self::assertEquals(5, AddressType::WORK); self::assertEquals(5, AddressType::WORK);
self::assertEquals(6, AddressType::CONTRACT); self::assertEquals(6, AddressType::CONTRACT);
self::assertEquals(7, AddressType::OTHER); self::assertEquals(7, AddressType::OTHER);
self::assertEquals(8, AddressType::EDUCATION);
} }
} }

View File

@ -39,6 +39,22 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase
$this->markTestSkipped( $this->markTestSkipped(
'The ftp connection is not available.' 'The ftp connection is not available.'
); );
} else {
try {
$mkdir = \ftp_mkdir(self::$con, '0xFF');
\ftp_rmdir(self::$con, '0xFF');
$put = \ftp_put(self::$con, '0x00');
\ftp_delete(self::$con, '0x00');
if (!$mkdir || !$put) {
throw new \Exception();
}
} catch (\Throwable $t) {
$this->markTestSkipped(
'No write permissions on ftp server.'
);
}
} }
} }

View File

@ -41,6 +41,22 @@ class FileTest extends \PHPUnit\Framework\TestCase
$this->markTestSkipped( $this->markTestSkipped(
'The ftp connection is not available.' 'The ftp connection is not available.'
); );
} else {
try {
$mkdir = \ftp_mkdir(self::$con, '0xFF');
\ftp_rmdir(self::$con, '0xFF');
$put = \ftp_put(self::$con, '0x00');
\ftp_delete(self::$con, '0x00');
if (!$mkdir || !$put) {
throw new \Exception();
}
} catch (\Throwable $t) {
$this->markTestSkipped(
'No write permissions on ftp server.'
);
}
} }
} }

View File

@ -38,10 +38,26 @@ class FtpStorageTest extends \PHPUnit\Framework\TestCase
protected function setUp() : void protected function setUp() : void
{ {
if (self::$con == false) { if (self::$con === false) {
$this->markTestSkipped( $this->markTestSkipped(
'The ftp connection is not available.' 'The ftp connection is not available.'
); );
} else {
try {
$mkdir = \ftp_mkdir(self::$con, '0xFF');
\ftp_rmdir(self::$con, '0xFF');
$put = \ftp_put(self::$con, '0x00');
\ftp_delete(self::$con, '0x00');
if (!$mkdir || !$put) {
throw new \Exception();
}
} catch (\Throwable $t) {
$this->markTestSkipped(
'No write permissions on ftp server.'
);
}
} }
FtpStorage::with(self::$con); FtpStorage::with(self::$con);

View File

@ -159,7 +159,7 @@ class StringUtilsTest extends \PHPUnit\Framework\TestCase
})); }));
self::assertEquals('abc', StringUtils::stringify(new class() implements RenderableInterface { self::assertEquals('abc', StringUtils::stringify(new class() implements RenderableInterface {
public function render() : string public function render(...$data) : string
{ {
return 'abc'; return 'abc';
} }

View File

@ -28,7 +28,7 @@ class TaskSchedulerTest extends \PHPUnit\Framework\TestCase
{ {
if (\stripos(\PHP_OS, 'WIN') === false) { if (\stripos(\PHP_OS, 'WIN') === false) {
$this->markTestSkipped( $this->markTestSkipped(
'The OS is not linux.' 'The OS is not windows.'
); );
} }
} }