mirror of
https://github.com/Karaka-Management/oms-Editor.git
synced 2026-01-28 09:18:41 +00:00
remove some getter/setter
This commit is contained in:
parent
6846f00ca5
commit
89053c804c
|
|
@ -82,13 +82,13 @@ final class ApiController extends Controller
|
|||
{
|
||||
if (!empty($val = $this->validateEditorCreate($request))) {
|
||||
$response->set('editor_create', new FormValidation($val));
|
||||
$response->getHeader()->setStatusCode(RequestStatusCode::R_400);
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$doc = $this->createDocFromRequest($request);
|
||||
$this->createModel($request->getHeader()->getAccount(), $doc, EditorDocMapper::class, 'doc', $request->getOrigin());
|
||||
$this->createModel($request->header->account, $doc, EditorDocMapper::class, 'doc', $request->getOrigin());
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Document', 'Document successfully created', $doc);
|
||||
}
|
||||
|
||||
|
|
@ -104,11 +104,11 @@ final class ApiController extends Controller
|
|||
private function createDocFromRequest(RequestAbstract $request) : EditorDoc
|
||||
{
|
||||
$doc = new EditorDoc();
|
||||
$doc->setTitle((string) ($request->getData('title') ?? ''));
|
||||
$doc->setPlain((string) ($request->getData('plain') ?? ''));
|
||||
$doc->setContent(Markdown::parse((string) ($request->getData('plain') ?? '')));
|
||||
$doc->title = (string) ($request->getData('title') ?? '');
|
||||
$doc->plaint = (string) ($request->getData('plain') ?? '');
|
||||
$doc->content = Markdown::parse((string) ($request->getData('plain') ?? ''));
|
||||
$doc->setVirtualPath((string) ($request->getData('virtualpath') ?? '/'));
|
||||
$doc->setCreatedBy(new NullAccount($request->getHeader()->getAccount()));
|
||||
$doc->createdBy = new NullAccount($request->header->account);
|
||||
|
||||
if (!empty($tags = $request->getDataJson('tags'))) {
|
||||
foreach ($tags as $tag) {
|
||||
|
|
@ -119,7 +119,7 @@ final class ApiController extends Controller
|
|||
|
||||
$internalResponse = new HttpResponse();
|
||||
$this->app->moduleManager->get('Tag')->apiTagCreate($request, $internalResponse, null);
|
||||
$doc->addTag($internalResponse->get($request->getUri()->__toString())['response']);
|
||||
$doc->addTag($internalResponse->get($request->uri->__toString())['response']);
|
||||
} else {
|
||||
$doc->addTag(new NullTag((int) $tag['id']));
|
||||
}
|
||||
|
|
@ -147,7 +147,7 @@ final class ApiController extends Controller
|
|||
/** @var \Modules\Editor\Models\EditorDoc $old */
|
||||
$old = clone EditorDocMapper::get((int) $request->getData('id'));
|
||||
$new = $this->updateEditorFromRequest($request);
|
||||
$this->updateModel($request->getHeader()->getAccount(), $old, $new, EditorDocMapper::class, 'doc', $request->getOrigin());
|
||||
$this->updateModel($request->header->account, $old, $new, EditorDocMapper::class, 'doc', $request->getOrigin());
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Document', 'Document successfully updated', $new);
|
||||
}
|
||||
|
||||
|
|
@ -164,9 +164,9 @@ final class ApiController extends Controller
|
|||
{
|
||||
/** @var \Modules\Editor\Models\EditorDoc $doc */
|
||||
$doc = EditorDocMapper::get((int) $request->getData('id'));
|
||||
$doc->setTitle((string) ($request->getData('title') ?? $doc->getTitle()));
|
||||
$doc->setPlain((string) ($request->getData('plain') ?? $doc->getPlain()));
|
||||
$doc->setContent(Markdown::parse((string) ($request->getData('plain') ?? $doc->getPlain())));
|
||||
$doc->title = (string) ($request->getData('title') ?? $doc->title);
|
||||
$doc->plaint = (string) ($request->getData('plain') ?? $doc->plain);
|
||||
$doc->content = Markdown::parse((string) ($request->getData('plain') ?? $doc->plain));
|
||||
|
||||
return $doc;
|
||||
}
|
||||
|
|
@ -208,7 +208,7 @@ final class ApiController extends Controller
|
|||
{
|
||||
/** @var \Modules\Editor\Models\EditorDoc $doc */
|
||||
$doc = EditorDocMapper::get((int) $request->getData('id'));
|
||||
$this->deleteModel($request->getHeader()->getAccount(), $doc, EditorDocMapper::class, 'doc', $request->getOrigin());
|
||||
$this->deleteModel($request->header->account, $doc, EditorDocMapper::class, 'doc', $request->getOrigin());
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Document', 'Document successfully deleted', $doc);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ final class BackendController extends Controller
|
|||
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1005301001, $request, $response));
|
||||
|
||||
$path = \str_replace('+', ' ', (string) ($request->getData('path') ?? '/'));
|
||||
$docs = EditorDocMapper::withConditional('language', $response->getLanguage())::getByVirtualPath($path, $request->getHeader()->getAccount());
|
||||
$docs = EditorDocMapper::withConditional('language', $response->getLanguage())::getByVirtualPath($path, $request->header->account);
|
||||
|
||||
list($collection, $parent) = CollectionMapper::getCollectionsByPath($path);
|
||||
|
||||
|
|
@ -133,14 +133,14 @@ final class BackendController extends Controller
|
|||
|
||||
/** @var \Modules\Editor\Models\EditorDoc $doc */
|
||||
$doc = EditorDocMapper::withConditional('language', $response->getLanguage())::get((int) $request->getData('id'));
|
||||
$accountId = $request->getHeader()->getAccount();
|
||||
$accountId = $request->header->account;
|
||||
|
||||
if ($doc->getCreatedBy()->getId() !== $accountId
|
||||
if ($doc->createdBy->getId() !== $accountId
|
||||
&& !$this->app->accountManager->get($accountId)->hasPermission(
|
||||
PermissionType::READ, $this->app->orgId, $this->app->appName, self::MODULE_NAME, PermissionState::DOC, $doc->getId())
|
||||
) {
|
||||
$view->setTemplate('/Web/Backend/Error/403_inline');
|
||||
$response->getHeader()->setStatusCode(RequestStatusCode::R_403);
|
||||
$response->header->status = RequestStatusCode::R_403;
|
||||
return $view;
|
||||
}
|
||||
|
||||
|
|
@ -179,14 +179,14 @@ final class BackendController extends Controller
|
|||
|
||||
/** @var \Modules\Editor\Models\EditorDoc $doc */
|
||||
$doc = EditorDocMapper::get((int) $request->getData('id'));
|
||||
$accountId = $request->getHeader()->getAccount();
|
||||
$accountId = $request->header->account;
|
||||
|
||||
if ($doc->getCreatedBy()->getId() !== $accountId
|
||||
if ($doc->createdBy->getId() !== $accountId
|
||||
&& !$this->app->accountManager->get($accountId)->hasPermission(
|
||||
PermissionType::READ, $this->app->orgId, $this->app->appName, self::MODULE_NAME, PermissionState::DOC, $doc->getId())
|
||||
) {
|
||||
$view->setTemplate('/Web/Backend/Error/403_inline');
|
||||
$response->getHeader()->setStatusCode(RequestStatusCode::R_403);
|
||||
$response->header->status = RequestStatusCode::R_403;
|
||||
return $view;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class EditorDoc implements \JsonSerializable, ArrayableInterface
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private string $title = '';
|
||||
public string $title = '';
|
||||
|
||||
/**
|
||||
* Content.
|
||||
|
|
@ -51,7 +51,7 @@ class EditorDoc implements \JsonSerializable, ArrayableInterface
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private string $content = '';
|
||||
public string $content = '';
|
||||
|
||||
/**
|
||||
* Unparsed.
|
||||
|
|
@ -59,7 +59,7 @@ class EditorDoc implements \JsonSerializable, ArrayableInterface
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private string $plain = '';
|
||||
public string $plain = '';
|
||||
|
||||
/**
|
||||
* Doc path for organizing.
|
||||
|
|
@ -75,7 +75,7 @@ class EditorDoc implements \JsonSerializable, ArrayableInterface
|
|||
* @var \DateTimeImmutable
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private \DateTimeImmutable $createdAt;
|
||||
public \DateTimeImmutable $createdAt;
|
||||
|
||||
/**
|
||||
* Creator.
|
||||
|
|
@ -83,7 +83,7 @@ class EditorDoc implements \JsonSerializable, ArrayableInterface
|
|||
* @var Account
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private Account $createdBy;
|
||||
public Account $createdBy;
|
||||
|
||||
/**
|
||||
* Tags.
|
||||
|
|
@ -104,70 +104,6 @@ class EditorDoc implements \JsonSerializable, ArrayableInterface
|
|||
$this->createdAt = new \DateTimeImmutable('now');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the content
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getContent() : string
|
||||
{
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the content
|
||||
*
|
||||
* @param string $content Content
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setContent(string $content) : void
|
||||
{
|
||||
$this->content = $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the plain text
|
||||
*
|
||||
* @param string $plain Plain text
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setPlain(string $plain) : void
|
||||
{
|
||||
$this->plain = $plain;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plain text
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getPlain() : string
|
||||
{
|
||||
return $this->plain;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get created at
|
||||
*
|
||||
* @return \DateTimeImmutable
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getCreatedAt() : \DateTimeImmutable
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the id
|
||||
*
|
||||
|
|
@ -180,56 +116,6 @@ class EditorDoc implements \JsonSerializable, ArrayableInterface
|
|||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get created by
|
||||
*
|
||||
* @return Account
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getCreatedBy() : Account
|
||||
{
|
||||
return $this->createdBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set created by
|
||||
*
|
||||
* @param Account $account Creator
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setCreatedBy(Account $account) : void
|
||||
{
|
||||
$this->createdBy = $account;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the title
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getTitle() : string
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the title
|
||||
*
|
||||
* @param string $title Title
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setTitle(string $title)
|
||||
{
|
||||
$this->title = $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path
|
||||
*
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class TextView extends View
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private string $name = '';
|
||||
public string $name = '';
|
||||
|
||||
/**
|
||||
* Form id
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ echo $this->getData('nav')->render(); ?>
|
|||
<div class="portlet-body">
|
||||
<form id="fEditor" method="<?= $isNewDoc ? 'PUT' : 'POST'; ?>" action="<?= UriFactory::build('{/api}editor?{?}&csrf={$CSRF}'); ?>">
|
||||
<div class="ipt-wrap">
|
||||
<div class="ipt-first"><input name="title" type="text" class="wf-100" value="<?= $doc->getTitle(); ?>"></div>
|
||||
<div class="ipt-first"><input name="title" type="text" class="wf-100" value="<?= $doc->title; ?>"></div>
|
||||
<div class="ipt-second"><input type="submit" value="<?= $this->getHtml('Save'); ?>"></div>
|
||||
</div>
|
||||
</form>
|
||||
|
|
@ -46,8 +46,8 @@ echo $this->getData('nav')->render(); ?>
|
|||
'editor',
|
||||
'plain',
|
||||
'fEditor',
|
||||
$doc->getPlain(),
|
||||
$doc->getContent()
|
||||
$doc->plain,
|
||||
$doc->content
|
||||
); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -69,21 +69,21 @@ echo $this->getData('nav')->render(); ?>
|
|||
<td><?= $this->getHtml('Created'); ?>
|
||||
<tbody>
|
||||
<?php $count = 0; foreach ($collections as $key => $value) : ++$count;
|
||||
$url = UriFactory::build('{/prefix}editor/list?path=' . \rtrim($value->getVirtualPath(), '/') . '/' . $value->getName());
|
||||
$url = UriFactory::build('{/prefix}editor/list?path=' . \rtrim($value->getVirtualPath(), '/') . '/' . $value->name);
|
||||
?>
|
||||
<tr data-href="<?= $url; ?>">
|
||||
<td><a href="<?= $url; ?>"><i class="fa fa-folder-open"></i></a>
|
||||
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->getName()); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->getCreatedBy()->getName1()); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->getCreatedAt()->format('Y-m-d')); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->name); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->createdBy->name1); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->createdAt->format('Y-m-d')); ?></a>
|
||||
<?php endforeach; ?>
|
||||
<?php foreach ($docs as $key => $value) : ++$count;
|
||||
$url = UriFactory::build('{/prefix}editor/single?{?}&id=' . $value->getId()); ?>
|
||||
<tr tabindex="0" data-href="<?= $url; ?>">
|
||||
<td><i class="fa fa-file-o"></i>
|
||||
<td data-label="<?= $this->getHtml('Title'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getTitle()); ?></a>
|
||||
<td data-label="<?= $this->getHtml('Creator'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getCreatedBy()->getName1()); ?></a>
|
||||
<td data-label="<?= $this->getHtml('Created'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getCreatedAt()->format('Y-m-d H:i:s')); ?></a>
|
||||
<td data-label="<?= $this->getHtml('Title'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->title); ?></a>
|
||||
<td data-label="<?= $this->getHtml('Creator'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->createdBy->name1); ?></a>
|
||||
<td data-label="<?= $this->getHtml('Created'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->createdAt->format('Y-m-d H:i:s')); ?></a>
|
||||
<?php endforeach; ?>
|
||||
<?php if ($count === 0) : ?>
|
||||
<tr><td colspan="4" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
|
||||
|
|
|
|||
|
|
@ -29,10 +29,10 @@ echo $this->getData('nav')->render(); ?>
|
|||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<section class="portlet">
|
||||
<div class="portlet-head"><?= $this->printHtml($doc->getTitle()); ?></div>
|
||||
<div class="portlet-head"><?= $this->printHtml($doc->title); ?></div>
|
||||
<div calss="portlet-body">
|
||||
<article>
|
||||
<?= $doc->getContent(); ?>
|
||||
<?= $doc->content; ?>
|
||||
</article>
|
||||
<?php if ($editable || !empty($tags)) : ?>
|
||||
<div class="portlet-foot">
|
||||
|
|
|
|||
|
|
@ -98,13 +98,13 @@ class ApiControllerTest extends \PHPUnit\Framework\TestCase
|
|||
$response = new HttpResponse();
|
||||
$request = new HttpRequest(new HttpUri(''));
|
||||
|
||||
$request->getHeader()->setAccount(1);
|
||||
$request->header->account = 1;
|
||||
$request->setData('title', 'Controller Test Title');
|
||||
$request->setData('plain', 'Controller Test Description');
|
||||
|
||||
$this->module->apiEditorCreate($request, $response);
|
||||
|
||||
self::assertEquals('Controller Test Title', $response->get('')['response']->getTitle());
|
||||
self::assertEquals('Controller Test Title', $response->get('')['response']->title);
|
||||
self::assertGreaterThan(0, $response->get('')['response']->getId());
|
||||
}
|
||||
|
||||
|
|
@ -121,14 +121,14 @@ class ApiControllerTest extends \PHPUnit\Framework\TestCase
|
|||
$response = new HttpResponse();
|
||||
$request = new HttpRequest(new HttpUri(''));
|
||||
|
||||
$request->getHeader()->setAccount(1);
|
||||
$request->header->account = 1;
|
||||
$request->setData('title', 'Controller Test With Tag');
|
||||
$request->setData('plain', 'Controller Test Description');
|
||||
$request->setData('tag', '[' . $tagId . ']');
|
||||
|
||||
$this->module->apiEditorCreate($request, $response);
|
||||
|
||||
self::assertEquals('Controller Test With Tag', $response->get('')['response']->getTitle());
|
||||
self::assertEquals('Controller Test With Tag', $response->get('')['response']->title);
|
||||
self::assertGreaterThan(0, $response->get('')['response']->getId());
|
||||
}
|
||||
|
||||
|
|
@ -141,12 +141,12 @@ class ApiControllerTest extends \PHPUnit\Framework\TestCase
|
|||
$response = new HttpResponse();
|
||||
$request = new HttpRequest(new HttpUri(''));
|
||||
|
||||
$request->getHeader()->setAccount(1);
|
||||
$request->header->account = 1;
|
||||
$request->setData('title', 'Controller Test Title');
|
||||
|
||||
$this->module->apiEditorCreate($request, $response);
|
||||
|
||||
self::assertEquals(RequestStatusCode::R_400, $response->getHeader()->getStatusCode());
|
||||
self::assertEquals(RequestStatusCode::R_400, $response->header->status);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -158,14 +158,14 @@ class ApiControllerTest extends \PHPUnit\Framework\TestCase
|
|||
$response = new HttpResponse();
|
||||
$request = new HttpRequest(new HttpUri(''));
|
||||
|
||||
$request->getHeader()->setAccount(1);
|
||||
$request->header->account = 1;
|
||||
$request->setData('id', '1');
|
||||
$request->setData('title', 'Changed Title');
|
||||
|
||||
$this->module->apiEditorUpdate($request, $response);
|
||||
|
||||
self::assertEquals('Changed Title', $response->get('')['response']->getTitle());
|
||||
self::assertEquals('Changed Title', EditorDocMapper::get(1)->getTitle());
|
||||
self::assertEquals('Changed Title', $response->get('')['response']->title);
|
||||
self::assertEquals('Changed Title', EditorDocMapper::get(1)->title);
|
||||
self::assertEquals(1, $response->get('')['response']->getId());
|
||||
}
|
||||
|
||||
|
|
@ -178,12 +178,12 @@ class ApiControllerTest extends \PHPUnit\Framework\TestCase
|
|||
$response = new HttpResponse();
|
||||
$request = new HttpRequest(new HttpUri(''));
|
||||
|
||||
$request->getHeader()->setAccount(1);
|
||||
$request->header->account = 1;
|
||||
$request->setData('id', '1');
|
||||
|
||||
$this->module->apiEditorGet($request, $response);
|
||||
|
||||
self::assertEquals('Changed Title', $response->get('')['response']->getTitle());
|
||||
self::assertEquals('Changed Title', $response->get('')['response']->title);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -193,16 +193,16 @@ class ApiControllerTest extends \PHPUnit\Framework\TestCase
|
|||
public function testDeleteEditorDoc() : void
|
||||
{
|
||||
$doc = new EditorDoc();
|
||||
$doc->setTitle('TestTitle');
|
||||
$doc->setContent('TestContent');
|
||||
$doc->setCreatedBy(new NullAccount(1));
|
||||
$doc->title = 'TestTitle';
|
||||
$doc->content = 'TestContent';
|
||||
$doc->createdBy = new NullAccount(1);
|
||||
|
||||
$docId = EditorDocMapper::create($doc);
|
||||
|
||||
$response = new HttpResponse();
|
||||
$request = new HttpRequest(new HttpUri(''));
|
||||
|
||||
$request->getHeader()->setAccount(1);
|
||||
$request->header->account = 1;
|
||||
$request->setData('id', $docId);
|
||||
|
||||
$this->module->apiEditorDelete($request, $response);
|
||||
|
|
|
|||
|
|
@ -32,21 +32,21 @@ class EditorDocMapperTest extends \PHPUnit\Framework\TestCase
|
|||
{
|
||||
$doc = new EditorDoc();
|
||||
|
||||
$doc->setCreatedBy(new NullAccount(1));
|
||||
$doc->setTitle('Title');
|
||||
$doc->setContent('Content');
|
||||
$doc->setPath('/some/test/path');
|
||||
$doc->createdBy = new NullAccount(1);
|
||||
$doc->title = 'Title';
|
||||
$doc->content = 'Content';
|
||||
$doc->setVirtualPath('/some/test/path');
|
||||
|
||||
$id = EditorDocMapper::create($doc);
|
||||
self::assertGreaterThan(0, $doc->getId());
|
||||
self::assertEquals($id, $doc->getId());
|
||||
|
||||
$docR = EditorDocMapper::get($doc->getId());
|
||||
self::assertEquals($doc->getCreatedAt()->format('Y-m-d'), $docR->getCreatedAt()->format('Y-m-d'));
|
||||
self::assertEquals($doc->getCreatedBy()->getId(), $docR->getCreatedBy()->getId());
|
||||
self::assertEquals($doc->getContent(), $docR->getContent());
|
||||
self::assertEquals($doc->getTitle(), $docR->getTitle());
|
||||
self::assertEquals($doc->getPath(), $docR->getPath());
|
||||
self::assertEquals($doc->createdAt->format('Y-m-d'), $docR->createdAt->format('Y-m-d'));
|
||||
self::assertEquals($doc->createdBy->getId(), $docR->createdBy->getId());
|
||||
self::assertEquals($doc->content, $docR->content);
|
||||
self::assertEquals($doc->title, $docR->title);
|
||||
self::assertEquals($doc->getVirtualPath(), $docR->getVirtualPath());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -62,10 +62,10 @@ class EditorDocMapperTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
// Test other
|
||||
|
||||
$doc->setCreatedBy(new NullAccount(\mt_rand(1, 1)));
|
||||
$doc->setTitle($text->generateText(\mt_rand(3, 7)));
|
||||
$doc->setContent($text->generateText(\mt_rand(20, 500)));
|
||||
$doc->setPath('/some/test/path');
|
||||
$doc->createdBy = new NullAccount(\mt_rand(1, 1));
|
||||
$doc->title = $text->generateText(\mt_rand(3, 7));
|
||||
$doc->content = $text->generateText(\mt_rand(20, 500));
|
||||
$doc->setVirtualPath('/some/test/path');
|
||||
|
||||
$id = EditorDocMapper::create($doc);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,12 +37,12 @@ class EditorDocTest extends \PHPUnit\Framework\TestCase
|
|||
public function testDefault() : void
|
||||
{
|
||||
self::assertEquals(0, $this->doc->getId());
|
||||
self::assertEquals(0, $this->doc->getCreatedBy()->getId());
|
||||
self::assertEquals('', $this->doc->getTitle());
|
||||
self::assertEquals('', $this->doc->getContent());
|
||||
self::assertEquals('', $this->doc->getPlain());
|
||||
self::assertEquals(0, $this->doc->createdBy->getId());
|
||||
self::assertEquals('', $this->doc->title);
|
||||
self::assertEquals('', $this->doc->content);
|
||||
self::assertEquals('', $this->doc->plain);
|
||||
self::assertEquals([], $this->doc->getTags());
|
||||
self::assertEquals((new \DateTime('now'))->format('Y-m-d'), $this->doc->getCreatedAt()->format('Y-m-d'));
|
||||
self::assertEquals((new \DateTime('now'))->format('Y-m-d'), $this->doc->createdAt->format('Y-m-d'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -51,8 +51,8 @@ class EditorDocTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testCreatedByInputOutput() : void
|
||||
{
|
||||
$this->doc->setCreatedBy(new NullAccount(1));
|
||||
self::assertEquals(1, $this->doc->getCreatedBy()->getId());
|
||||
$this->doc->createdBy = new NullAccount(1);
|
||||
self::assertEquals(1, $this->doc->createdBy->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -61,8 +61,8 @@ class EditorDocTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testTitleInputOutput() : void
|
||||
{
|
||||
$this->doc->setTitle('Title');
|
||||
self::assertEquals('Title', $this->doc->getTitle());
|
||||
$this->doc->title = 'Title';
|
||||
self::assertEquals('Title', $this->doc->title);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -71,8 +71,8 @@ class EditorDocTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testContentInputOutput() : void
|
||||
{
|
||||
$this->doc->setContent('Content');
|
||||
self::assertEquals('Content', $this->doc->getContent());
|
||||
$this->doc->content = 'Content';
|
||||
self::assertEquals('Content', $this->doc->content);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -81,8 +81,8 @@ class EditorDocTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testPlainInputOutput() : void
|
||||
{
|
||||
$this->doc->setPlain('Plain');
|
||||
self::assertEquals('Plain', $this->doc->getPlain());
|
||||
$this->doc->plain = 'Plain';
|
||||
self::assertEquals('Plain', $this->doc->plain);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -91,8 +91,8 @@ class EditorDocTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testPathInputOutput() : void
|
||||
{
|
||||
$this->doc->setPath('/some/test/path');
|
||||
self::assertEquals('/some/test/path', $this->doc->getPath());
|
||||
$this->doc->setVirtualPath('/some/test/path');
|
||||
self::assertEquals('/some/test/path', $this->doc->getVirtualPath());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -114,18 +114,18 @@ class EditorDocTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testSerialization() : void
|
||||
{
|
||||
$this->doc->setCreatedBy(new NullAccount(1));
|
||||
$this->doc->setTitle('Title');
|
||||
$this->doc->setContent('Content');
|
||||
$this->doc->setPlain('Plain');
|
||||
$this->doc->setPath('/some/path');
|
||||
$this->doc->createdBy = new NullAccount(1);
|
||||
$this->doc->title = 'Title';
|
||||
$this->doc->content = 'Content';
|
||||
$this->doc->plaint = 'Plain';
|
||||
$this->doc->setVirtualPath('/some/path');
|
||||
$arr = [
|
||||
'id' => 0,
|
||||
'title' => $this->doc->getTitle(),
|
||||
'plain' => $this->doc->getPlain(),
|
||||
'content' => $this->doc->getContent(),
|
||||
'createdAt' => $this->doc->getCreatedAt(),
|
||||
'createdBy' => $this->doc->getCreatedBy(),
|
||||
'title' => $this->doc->title,
|
||||
'plain' => $this->doc->plain,
|
||||
'content' => $this->doc->content,
|
||||
'createdAt' => $this->doc->createdAt,
|
||||
'createdBy' => $this->doc->createdBy,
|
||||
];
|
||||
self::assertEquals($arr, $this->doc->toArray());
|
||||
self::assertEquals($arr, $this->doc->jsonSerialize());
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user