cs fixes, bug fixes, code coverage

This commit is contained in:
Dennis Eichhorn 2021-11-16 00:05:43 +01:00
parent 3185b8417e
commit a1e9ca2c92
12 changed files with 38 additions and 42 deletions

View File

@ -12,9 +12,7 @@ If you have a good idea for improvement feel free to create a new issue with all
### Issues ### Issues
Feel free to grab any open issue implement it and create a new pull request. Most issues can be found in the `Project.md` file in the `Docs` repository. Feel free to grab any open issue implement it and create a new pull request. Most issues can be found in the code marked with `@todo` or in the [PROJECT.md](https://github.com/Orange-Management/Docs/blob/master/Project/PROJECT.md) file.
The issue information can be used to provide additional information such as priority, difficulty and type. For your first issue try to find a issue marked `[d:first]` or `[d:beginner]`.
### Code Style ### Code Style

View File

@ -220,7 +220,7 @@ final class ApiController extends Controller
*/ */
private function createWikiCategoryL11nFromRequest(RequestAbstract $request) : WikiCategoryL11n private function createWikiCategoryL11nFromRequest(RequestAbstract $request) : WikiCategoryL11n
{ {
$l11nWikiCategory = new WikiCategoryL11n(); $l11nWikiCategory = new WikiCategoryL11n();
$l11nWikiCategory->category = (int) ($request->getData('category') ?? 0); $l11nWikiCategory->category = (int) ($request->getData('category') ?? 0);
$l11nWikiCategory->setLanguage((string) ( $l11nWikiCategory->setLanguage((string) (
$request->getData('language') ?? $request->getLanguage() $request->getData('language') ?? $request->getLanguage()
@ -281,7 +281,7 @@ final class ApiController extends Controller
*/ */
private function updateDocFromRequest(RequestAbstract $request) : WikiDoc private function updateDocFromRequest(RequestAbstract $request) : WikiDoc
{ {
$doc = WikiDocMapper::get((int) $request->getData('id')); $doc = WikiDocMapper::get((int) $request->getData('id'));
$doc->name = (string) ($request->getData('title') ?? $doc->name); $doc->name = (string) ($request->getData('title') ?? $doc->name);
return $doc; return $doc;
@ -567,7 +567,7 @@ final class ApiController extends Controller
*/ */
private function updateAppFromRequest(RequestAbstract $request) : WikiApp private function updateAppFromRequest(RequestAbstract $request) : WikiApp
{ {
$app = WikiAppMapper::get((int) $request->getData('id')); $app = WikiAppMapper::get((int) $request->getData('id'));
$app->name = (string) ($request->getData('name') ?? $app->name); $app->name = (string) ($request->getData('name') ?? $app->name);
return $app; return $app;

View File

@ -132,8 +132,8 @@ class WikiCategory implements \JsonSerializable
public function toArray() : array public function toArray() : array
{ {
return [ return [
'id' => $this->id, 'id' => $this->id,
'app' => $this->app, 'app' => $this->app,
'virtualPath' => $this->virtualPath, 'virtualPath' => $this->virtualPath,
]; ];
} }

View File

@ -101,9 +101,9 @@ final class WikiCategoryMapper extends DataMapperAbstract
/** /**
* Get by parent. * Get by parent.
* *
* @param int $value Parent value id * @param int $value Parent value id
* @param int $app App * @param int $app App
* @param int $depth Relation depth * @param int $depth Relation depth
* *
* @return array * @return array
* *

View File

@ -18,7 +18,6 @@ use Modules\Media\Models\Media;
use Modules\Tag\Models\Tag; use Modules\Tag\Models\Tag;
use phpOMS\Localization\ISO639x1Enum; use phpOMS\Localization\ISO639x1Enum;
/** /**
* Wiki document class. * Wiki document class.
* *
@ -233,15 +232,15 @@ class WikiDoc implements \JsonSerializable
public function toArray() : array public function toArray() : array
{ {
return [ return [
'id' => $this->id, 'id' => $this->id,
'app' => $this->app, 'app' => $this->app,
'name' => $this->name, 'name' => $this->name,
'status' => $this->status, 'status' => $this->status,
'doc' => $this->doc, 'doc' => $this->doc,
'docRaw' => $this->docRaw, 'docRaw' => $this->docRaw,
'language' => $this->language, 'language' => $this->language,
'tags' => $this->tags, 'tags' => $this->tags,
'media' => $this->media, 'media' => $this->media,
]; ];
} }

View File

@ -16,7 +16,6 @@ namespace Modules\Knowledgebase\tests\Models;
use Modules\Knowledgebase\Models\WikiApp; use Modules\Knowledgebase\Models\WikiApp;
use Modules\Knowledgebase\Models\WikiAppMapper; use Modules\Knowledgebase\Models\WikiAppMapper;
use phpOMS\Utils\RnG\Text;
/** /**
* @testdox Modules\tests\Knowledgebase\Models\WikiAppMapperTest: Wiki application mapper * @testdox Modules\tests\Knowledgebase\Models\WikiAppMapperTest: Wiki application mapper

View File

@ -67,7 +67,7 @@ final class WikiAppTest extends \PHPUnit\Framework\TestCase
self::assertEquals( self::assertEquals(
[ [
'id' => 0, 'id' => 0,
'name' => 'Title', 'name' => 'Title',
], ],
$serialized $serialized

View File

@ -70,16 +70,16 @@ final class WikiCategoryL11nTest extends \PHPUnit\Framework\TestCase
*/ */
public function testSerialize() : void public function testSerialize() : void
{ {
$this->l11n->name = 'Title'; $this->l11n->name = 'Title';
$this->l11n->category = 2; $this->l11n->category = 2;
$this->l11n->setLanguage(ISO639x1Enum::_DE); $this->l11n->setLanguage(ISO639x1Enum::_DE);
self::assertEquals( self::assertEquals(
[ [
'id' => 0, 'id' => 0,
'name' => 'Title', 'name' => 'Title',
'category' => 2, 'category' => 2,
'language' => ISO639x1Enum::_DE, 'language' => ISO639x1Enum::_DE,
], ],
$this->l11n->jsonSerialize() $this->l11n->jsonSerialize()
); );

View File

@ -14,10 +14,10 @@ declare(strict_types=1);
namespace Modules\Knowledgebase\tests\Models; namespace Modules\Knowledgebase\tests\Models;
use Modules\Knowledgebase\Models\NullWikiApp;
use Modules\Knowledgebase\Models\NullWikiCategory; use Modules\Knowledgebase\Models\NullWikiCategory;
use Modules\Knowledgebase\Models\WikiCategory; use Modules\Knowledgebase\Models\WikiCategory;
use Modules\Knowledgebase\Models\WikiCategoryMapper; use Modules\Knowledgebase\Models\WikiCategoryMapper;
use phpOMS\Utils\RnG\Text;
/** /**
* @testdox Modules\tests\Knowledgebase\Models\WikiCategoryMapperTest: Wiki category mapper * @testdox Modules\tests\Knowledgebase\Models\WikiCategoryMapperTest: Wiki category mapper
@ -62,6 +62,7 @@ final class WikiCategoryMapperTest extends \PHPUnit\Framework\TestCase
*/ */
public function testChildCR() : void public function testChildCR() : void
{ {
$this->category->app = new NullWikiApp(1);
$this->category->setL11n('Test Category2'); $this->category->setL11n('Test Category2');
$this->category->parent = new NullWikiCategory(1); $this->category->parent = new NullWikiCategory(1);

View File

@ -103,15 +103,15 @@ final class WikiCategoryTest extends \PHPUnit\Framework\TestCase
*/ */
public function testSerialize() : void public function testSerialize() : void
{ {
$this->category->app = new NullWikiApp(1); $this->category->app = new NullWikiApp(1);
$this->category->virtualPath = '/test/path'; $this->category->virtualPath = '/test/path';
$serialized = $this->category->jsonSerialize(); $serialized = $this->category->jsonSerialize();
self::assertEquals( self::assertEquals(
[ [
'id' => 0, 'id' => 0,
'app' => $this->category->app, 'app' => $this->category->app,
'virtualPath' => '/test/path', 'virtualPath' => '/test/path',
], ],
$serialized $serialized

View File

@ -18,7 +18,6 @@ use Modules\Knowledgebase\Models\NullWikiCategory;
use Modules\Knowledgebase\Models\WikiDoc; use Modules\Knowledgebase\Models\WikiDoc;
use Modules\Knowledgebase\Models\WikiDocMapper; use Modules\Knowledgebase\Models\WikiDocMapper;
use Modules\Knowledgebase\Models\WikiStatus; use Modules\Knowledgebase\Models\WikiStatus;
use phpOMS\Utils\RnG\Text;
/** /**
* @testdox Modules\tests\Knowledgebase\Models\WikiDocMapperTest: Wiki document mapper * @testdox Modules\tests\Knowledgebase\Models\WikiDocMapperTest: Wiki document mapper

View File

@ -18,8 +18,8 @@ use Modules\Knowledgebase\Models\NullWikiApp;
use Modules\Knowledgebase\Models\NullWikiCategory; use Modules\Knowledgebase\Models\NullWikiCategory;
use Modules\Knowledgebase\Models\WikiDoc; use Modules\Knowledgebase\Models\WikiDoc;
use Modules\Knowledgebase\Models\WikiStatus; use Modules\Knowledgebase\Models\WikiStatus;
use Modules\Tag\Models\NullTag;
use Modules\Media\Models\Media; use Modules\Media\Models\Media;
use Modules\Tag\Models\NullTag;
use phpOMS\Localization\ISO639x1Enum; use phpOMS\Localization\ISO639x1Enum;
/** /**
@ -161,25 +161,25 @@ final class WikiDocTest extends \PHPUnit\Framework\TestCase
*/ */
public function testSerialize() : void public function testSerialize() : void
{ {
$this->doc->app = new NullWikiApp(1); $this->doc->app = new NullWikiApp(1);
$this->doc->name = '/test/path'; $this->doc->name = '/test/path';
$this->doc->setStatus(WikiStatus::DRAFT); $this->doc->setStatus(WikiStatus::DRAFT);
$this->doc->doc = 'TestDoc'; $this->doc->doc = 'TestDoc';
$this->doc->docRaw = 'TestDocRaw'; $this->doc->docRaw = 'TestDocRaw';
$serialized = $this->doc->jsonSerialize(); $serialized = $this->doc->jsonSerialize();
self::assertEquals( self::assertEquals(
[ [
'id' => 0, 'id' => 0,
'app' => $this->doc->app, 'app' => $this->doc->app,
'name' => '/test/path', 'name' => '/test/path',
'status' => WikiStatus::DRAFT, 'status' => WikiStatus::DRAFT,
'doc' => 'TestDoc', 'doc' => 'TestDoc',
'docRaw' => 'TestDocRaw', 'docRaw' => 'TestDocRaw',
'language' => ISO639x1Enum::_EN, 'language' => ISO639x1Enum::_EN,
'tags' => [], 'tags' => [],
'media' => [], 'media' => [],
], ],
$serialized $serialized
); );