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
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.
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]`.
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.
### Code Style

View File

@ -220,7 +220,7 @@ final class ApiController extends Controller
*/
private function createWikiCategoryL11nFromRequest(RequestAbstract $request) : WikiCategoryL11n
{
$l11nWikiCategory = new WikiCategoryL11n();
$l11nWikiCategory = new WikiCategoryL11n();
$l11nWikiCategory->category = (int) ($request->getData('category') ?? 0);
$l11nWikiCategory->setLanguage((string) (
$request->getData('language') ?? $request->getLanguage()
@ -281,7 +281,7 @@ final class ApiController extends Controller
*/
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);
return $doc;
@ -567,7 +567,7 @@ final class ApiController extends Controller
*/
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);
return $app;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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