new datamapper mostly implemented

This commit is contained in:
Dennis Eichhorn 2021-12-11 11:54:17 +01:00
parent 37496a6469
commit 89b356a58d
13 changed files with 100 additions and 81 deletions

View File

@ -1 +1,20 @@
[{"type":"setting","name":"1004700001","content":"1","module":"Organization"},{"type":"setting","name":"1004700002","content":"1","module":"Organization"},{"type":"setting","name":"1004700003","content":"1","module":"Organization"}]
[
{
"type": "setting",
"name": "1004700001",
"content": "1",
"module": "Organization"
},
{
"type": "setting",
"name": "1004700002",
"content": "1",
"module": "Organization"
},
{
"type": "setting",
"name": "1004700003",
"content": "1",
"module": "Organization"
}
]

View File

@ -39,7 +39,7 @@ class Admin
public static function install(string $path, ApplicationAbstract $app) : void
{
$settings = include __DIR__ . '/Admin.install.php';
\file_put_contents(__DIR__ . '/Admin.install.json', \json_encode($settings));
\file_put_contents(__DIR__ . '/Admin.install.json', \json_encode($settings, \JSON_PRETTY_PRINT));
\Modules\Admin\Admin\Installer::installExternal($app, ['path' => __DIR__ . '/Admin.install.json']);
}

View File

@ -61,6 +61,6 @@ final class Installer extends InstallerAbstract
$unit = new Unit();
$unit->name = 'Orange Management';
UnitMapper::create($unit);
UnitMapper::create()->execute($unit);
}
}

View File

@ -89,7 +89,7 @@ final class ApiController extends Controller
public function apiUnitGet(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
{
/** @var Unit $unit */
$unit = UnitMapper::get((int) $request->getData('id'));
$unit = UnitMapper::get()->where('id', (int) $request->getData('id'))->execute();
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Unit', 'Unit successfully returned.', $unit);
}
@ -109,7 +109,7 @@ final class ApiController extends Controller
public function apiUnitSet(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
{
/** @var Unit $old */
$old = clone UnitMapper::get((int) $request->getData('id'));
$old = clone UnitMapper::get()->where('id', (int) $request->getData('id'))->execute();
$new = $this->updateUnitFromRequest($request);
$this->updateModel($request->header->account, $old, $new, UnitMapper::class, 'unit', $request->getOrigin());
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Unit', 'Unit successfully updated.', $new);
@ -127,7 +127,7 @@ final class ApiController extends Controller
private function updateUnitFromRequest(RequestAbstract $request) : Unit
{
/** @var Unit $unit */
$unit = UnitMapper::get((int) $request->getData('id'));
$unit = UnitMapper::get()->where('id', (int) $request->getData('id'))->execute();
$unit->name = (string) ($request->getData('name') ?? $unit->name);
$unit->descriptionRaw = (string) ($request->getData('description') ?? $unit->descriptionRaw);
$unit->description = Markdown::parse((string) ($request->getData('description') ?? $unit->descriptionRaw));
@ -155,7 +155,7 @@ final class ApiController extends Controller
public function apiUnitDelete(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
{
/** @var Unit $unit */
$unit = UnitMapper::get((int) $request->getData('id'));
$unit = UnitMapper::get()->where('id', (int) $request->getData('id'))->execute();
$this->deleteModel($request->header->account, $unit, UnitMapper::class, 'unit', $request->getOrigin());
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Unit', 'Unit successfully deleted.', $unit);
}
@ -242,7 +242,7 @@ final class ApiController extends Controller
}
/** @var Unit $unit */
$unit = UnitMapper::get((int) ($request->getData('id') ?? 0));
$unit = UnitMapper::get()->where('id', (int) ($request->getData('id') ?? 0))->execute();
$old = clone $unit;
$uploaded = $this->app->moduleManager->get('Media')->uploadFiles(
@ -304,7 +304,7 @@ final class ApiController extends Controller
public function apiPositionGet(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
{
/** @var Position $position */
$position = PositionMapper::get((int) $request->getData('id'));
$position = PositionMapper::get()->where('id', (int) $request->getData('id'))->execute();
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Position', 'Position successfully returned.', $position);
}
@ -324,7 +324,7 @@ final class ApiController extends Controller
public function apiPositionDelete(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
{
/** @var Position $position */
$position = PositionMapper::get((int) $request->getData('id'));
$position = PositionMapper::get()->where('id', (int) $request->getData('id'))->execute();
$this->deleteModel($request->header->account, $position, PositionMapper::class, 'position', $request->getOrigin());
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Position', 'Position successfully deleted.', $position);
}
@ -345,7 +345,7 @@ final class ApiController extends Controller
public function apiPositionSet(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
{
/** @var Position $old */
$old = clone PositionMapper::get((int) $request->getData('id'));
$old = clone PositionMapper::get()->where('id', (int) $request->getData('id'))->execute();
$new = $this->updatePositionFromRequest($request);
$this->updateModel($request->header->account, $old, $new, PositionMapper::class, 'position', $request->getOrigin());
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Position', 'Position successfully updated.', $new);
@ -363,7 +363,7 @@ final class ApiController extends Controller
private function updatePositionFromRequest(RequestAbstract $request) : Position
{
/** @var Position $position */
$position = PositionMapper::get((int) $request->getData('id'));
$position = PositionMapper::get()->where('id', (int) $request->getData('id'))->execute();
$position->name = (string) ($request->getData('name') ?? $position->name);
$position->descriptionRaw = (string) ($request->getData('description') ?? $position->descriptionRaw);
$position->description = Markdown::parse((string) ($request->getData('description') ?? $position->descriptionRaw));
@ -482,7 +482,7 @@ final class ApiController extends Controller
public function apiDepartmentGet(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
{
/** @var Department $department */
$department = DepartmentMapper::get((int) $request->getData('id'));
$department = DepartmentMapper::get()->where('id', (int) $request->getData('id'))->execute();
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Department', 'Department successfully returned.', $department);
}
@ -502,7 +502,7 @@ final class ApiController extends Controller
public function apiDepartmentSet(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
{
/** @var Department $old */
$old = clone DepartmentMapper::get((int) $request->getData('id'));
$old = clone DepartmentMapper::get()->where('id', (int) $request->getData('id'))->execute();
$new = $this->updateDepartmentFromRequest($request);
$this->updateModel($request->header->account, $old, $new, DepartmentMapper::class, 'department', $request->getOrigin());
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Department', 'Department successfully updated.', $new);
@ -520,7 +520,7 @@ final class ApiController extends Controller
private function updateDepartmentFromRequest(RequestAbstract $request) : Department
{
/** @var Department $department */
$department = DepartmentMapper::get((int) $request->getData('id'));
$department = DepartmentMapper::get()->where('id', (int) $request->getData('id'))->execute();
$department->name = (string) ($request->getData('name') ?? $department->name);
$department->descriptionRaw = (string) ($request->getData('description') ?? $department->descriptionRaw);
$department->description = Markdown::parse((string) ($request->getData('description') ?? $department->descriptionRaw));
@ -551,7 +551,7 @@ final class ApiController extends Controller
public function apiDepartmentDelete(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
{
/** @var Department $department */
$department = DepartmentMapper::get((int) $request->getData('id'));
$department = DepartmentMapper::get()->where('id', (int) $request->getData('id'))->execute();
$this->deleteModel($request->header->account, $department, DepartmentMapper::class, 'department', $request->getOrigin());
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Department', 'Department successfully deleted.', $department);
}
@ -634,7 +634,7 @@ final class ApiController extends Controller
$response->set(
$request->uri->__toString(),
\array_values(
UnitMapper::find((string) ($request->getData('search') ?? ''))
UnitMapper::getAll()->where('name', '%' . ($request->getData('search') ?? '') . '%', 'LIKE')->execute()
)
);
}
@ -658,7 +658,7 @@ final class ApiController extends Controller
$response->set(
$request->uri->__toString(),
\array_values(
DepartmentMapper::find((string) ($request->getData('search') ?? ''))
DepartmentMapper::getAll()->where('name', '%' . ($request->getData('search') ?? '') . '%', 'LIKE')->execute()
)
);
}
@ -682,7 +682,7 @@ final class ApiController extends Controller
$response->set(
$request->uri->__toString(),
\array_values(
PositionMapper::find((string) ($request->getData('search') ?? ''))
PositionMapper::getAll()->where('name', '%' . ($request->getData('search') ?? '') . '%', 'LIKE')->execute()
)
);
}

View File

@ -58,11 +58,11 @@ final class BackendController extends Controller
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1004703001, $request, $response));
if ($request->getData('ptype') === 'p') {
$view->setData('units', UnitMapper::getBeforePivot((int) ($request->getData('id') ?? 0), null, 25));
$view->setData('units', UnitMapper::getAll()->with('parent')->with('image')->where('id', (int) ($request->getData('id') ?? 0), '<')->limit(25)->execute());
} elseif ($request->getData('ptype') === 'n') {
$view->setData('units', UnitMapper::getAfterPivot((int) ($request->getData('id') ?? 0), null, 25));
$view->setData('units', UnitMapper::getAll()->with('parent')->with('image')->where('id', (int) ($request->getData('id') ?? 0), '>')->limit(25)->execute());
} else {
$view->setData('units', UnitMapper::getAfterPivot(0, null, 25));
$view->setData('units', UnitMapper::getAll()->with('parent')->with('image')->where('id', 0, '>')->limit(25)->execute());
}
return $view;
@ -89,7 +89,7 @@ final class BackendController extends Controller
$selectorView = new \Modules\Organization\Theme\Backend\Components\UnitTagSelector\UnitTagSelectorView($this->app->l11nManager, $request, $response);
$view->addData('unit-selector', $selectorView);
$view->addData('unit', UnitMapper::get((int) $request->getData('id')));
$view->addData('unit', UnitMapper::get()->with('parent')->with('image')->where('id', (int) $request->getData('id'))->execute());
$editor = new \Modules\Editor\Theme\Backend\Components\Editor\BaseView($this->app->l11nManager, $request, $response);
$view->addData('editor', $editor);
@ -120,17 +120,17 @@ final class BackendController extends Controller
$view->setTemplate('/Modules/Organization/Theme/Backend/organigram');
/** @var Unit[] $units */
$units = UnitMapper::getAll();
$units = UnitMapper::getAll()->with('parent')->execute();
$unitTree = $this->createOrgTree($units);
$view->setData('unitTree', $unitTree);
/** @var Department[] $departments */
$departments = DepartmentMapper::getAll();
$departments = DepartmentMapper::getAll()->with('parent')->with('unit')->execute();
$depTree = $this->createOrgTree($departments);
$view->setData('departmentTree', $depTree);
/** @var Position[] $positions */
$positions = PositionMapper::getAll();
$positions = PositionMapper::getAll()->with('parent')->with('unit')->with('department')->execute();
$posTree = $this->createOrgTree($positions);
$view->setData('positionTree', $posTree);
@ -236,11 +236,11 @@ final class BackendController extends Controller
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1004704001, $request, $response));
if ($request->getData('ptype') === 'p') {
$view->setData('departments', DepartmentMapper::getBeforePivot((int) ($request->getData('id') ?? 0), null, 25));
$view->setData('departments', DepartmentMapper::getAll()->with('parent')->with('unit')->where('id', (int) ($request->getData('id') ?? 0), '<')->limit(25)->execute());
} elseif ($request->getData('ptype') === 'n') {
$view->setData('departments', DepartmentMapper::getAfterPivot((int) ($request->getData('id') ?? 0), null, 25));
$view->setData('departments', DepartmentMapper::getAll()->with('parent')->with('unit')->where('id', (int) ($request->getData('id') ?? 0), '>')->limit(25)->execute());
} else {
$view->setData('departments', DepartmentMapper::getAfterPivot(0, null, 25));
$view->setData('departments', DepartmentMapper::getAll()->with('parent')->with('unit')->where('id', 0, '>')->limit(25)->execute());
}
return $view;
@ -271,7 +271,7 @@ final class BackendController extends Controller
$unitSelectorView = new \Modules\Organization\Theme\Backend\Components\UnitTagSelector\UnitTagSelectorView($this->app->l11nManager, $request, $response);
$view->addData('unit-selector', $unitSelectorView);
$view->addData('department', DepartmentMapper::get((int) $request->getData('id')));
$view->addData('department', DepartmentMapper::get()->with('parent')->with('unit')->where('id', (int) $request->getData('id'))->execute());
$editor = new \Modules\Editor\Theme\Backend\Components\Editor\BaseView($this->app->l11nManager, $request, $response);
$view->addData('editor', $editor);
@ -330,11 +330,11 @@ final class BackendController extends Controller
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1004705001, $request, $response));
if ($request->getData('ptype') === 'p') {
$view->setData('positions', PositionMapper::getBeforePivot((int) ($request->getData('id') ?? 0), null, 25));
$view->setData('positions', PositionMapper::getAll()->with('parent')->with('department')->where('id', (int) ($request->getData('id') ?? 0), '<')->limit(25)->execute());
} elseif ($request->getData('ptype') === 'n') {
$view->setData('positions', PositionMapper::getAfterPivot((int) ($request->getData('id') ?? 0), null, 25));
$view->setData('positions', PositionMapper::getAll()->with('parent')->with('department')->where('id', (int) ($request->getData('id') ?? 0), '>')->limit(25)->execute());
} else {
$view->setData('positions', PositionMapper::getAfterPivot(0, null, 25));
$view->setData('positions', PositionMapper::getAll()->with('parent')->with('department')->where('id', 0, '>')->limit(25)->execute());
}
return $view;
@ -365,7 +365,7 @@ final class BackendController extends Controller
$departmentSelectorView = new \Modules\Organization\Theme\Backend\Components\DepartmentTagSelector\DepartmentTagSelectorView($this->app->l11nManager, $request, $response);
$view->addData('department-selector', $departmentSelectorView);
$view->addData('position', PositionMapper::get((int) $request->getData('id')));
$view->addData('position', PositionMapper::get()->with('parent')->with('department')->where('id', (int) $request->getData('id'))->execute());
$editor = new \Modules\Editor\Theme\Backend\Components\Editor\BaseView($this->app->l11nManager, $request, $response);
$view->addData('editor', $editor);

View File

@ -14,7 +14,7 @@ declare(strict_types=1);
namespace Modules\Organization\Models;
use phpOMS\DataStorage\Database\DataMapperAbstract;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
/**
* Organization department mapper class.
@ -24,7 +24,7 @@ use phpOMS\DataStorage\Database\DataMapperAbstract;
* @link https://orange-management.org
* @since 1.0.0
*/
final class DepartmentMapper extends DataMapperAbstract
final class DepartmentMapper extends DataMapperFactory
{
/**
* Columns.
@ -32,7 +32,7 @@ final class DepartmentMapper extends DataMapperAbstract
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
* @since 1.0.0
*/
protected static array $columns = [
public const COLUMNS = [
'organization_department_id' => ['name' => 'organization_department_id', 'type' => 'int', 'internal' => 'id'],
'organization_department_name' => ['name' => 'organization_department_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true],
'organization_department_description' => ['name' => 'organization_department_description', 'type' => 'string', 'internal' => 'description'],
@ -48,7 +48,7 @@ final class DepartmentMapper extends DataMapperAbstract
* @var array<string, array{mapper:string, external:string}>
* @since 1.0.0
*/
protected static array $belongsTo = [
public const BELONGS_TO = [
'unit' => [
'mapper' => UnitMapper::class,
'external' => 'organization_department_unit',
@ -65,7 +65,7 @@ final class DepartmentMapper extends DataMapperAbstract
* @var string
* @since 1.0.0
*/
protected static string $model = Department::class;
public const MODEL = Department::class;
/**
* Primary table.
@ -73,7 +73,7 @@ final class DepartmentMapper extends DataMapperAbstract
* @var string
* @since 1.0.0
*/
protected static string $table = 'organization_department';
public const TABLE = 'organization_department';
/**
* Primary field name.
@ -81,5 +81,5 @@ final class DepartmentMapper extends DataMapperAbstract
* @var string
* @since 1.0.0
*/
protected static string $primaryField = 'organization_department_id';
public const PRIMARYFIELD ='organization_department_id';
}

View File

@ -14,7 +14,7 @@ declare(strict_types=1);
namespace Modules\Organization\Models;
use phpOMS\DataStorage\Database\DataMapperAbstract;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
/**
* Organization position mapper class.
@ -24,7 +24,7 @@ use phpOMS\DataStorage\Database\DataMapperAbstract;
* @link https://orange-management.org
* @since 1.0.0
*/
final class PositionMapper extends DataMapperAbstract
final class PositionMapper extends DataMapperFactory
{
/**
* Columns.
@ -32,7 +32,7 @@ final class PositionMapper extends DataMapperAbstract
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
* @since 1.0.0
*/
protected static array $columns = [
public const COLUMNS = [
'organization_position_id' => ['name' => 'organization_position_id', 'type' => 'int', 'internal' => 'id'],
'organization_position_name' => ['name' => 'organization_position_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true],
'organization_position_description' => ['name' => 'organization_position_description', 'type' => 'string', 'internal' => 'description'],
@ -48,7 +48,7 @@ final class PositionMapper extends DataMapperAbstract
* @var array<string, array{mapper:string, external:string}>
* @since 1.0.0
*/
protected static array $belongsTo = [
public const BELONGS_TO = [
'parent' => [
'mapper' => self::class,
'external' => 'organization_position_parent',
@ -65,7 +65,7 @@ final class PositionMapper extends DataMapperAbstract
* @var string
* @since 1.0.0
*/
protected static string $model = Position::class;
public const MODEL = Position::class;
/**
* Primary table.
@ -73,7 +73,7 @@ final class PositionMapper extends DataMapperAbstract
* @var string
* @since 1.0.0
*/
protected static string $table = 'organization_position';
public const TABLE = 'organization_position';
/**
* Primary field name.
@ -81,5 +81,5 @@ final class PositionMapper extends DataMapperAbstract
* @var string
* @since 1.0.0
*/
protected static string $primaryField = 'organization_position_id';
public const PRIMARYFIELD ='organization_position_id';
}

View File

@ -15,7 +15,7 @@ declare(strict_types=1);
namespace Modules\Organization\Models;
use Modules\Media\Models\MediaMapper;
use phpOMS\DataStorage\Database\DataMapperAbstract;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
/**
* Organization unit mapper class.
@ -25,7 +25,7 @@ use phpOMS\DataStorage\Database\DataMapperAbstract;
* @link https://orange-management.org
* @since 1.0.0
*/
final class UnitMapper extends DataMapperAbstract
final class UnitMapper extends DataMapperFactory
{
/**
* Columns.
@ -33,7 +33,7 @@ final class UnitMapper extends DataMapperAbstract
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
* @since 1.0.0
*/
protected static array $columns = [
public const COLUMNS = [
'organization_unit_id' => ['name' => 'organization_unit_id', 'type' => 'int', 'internal' => 'id'],
'organization_unit_name' => ['name' => 'organization_unit_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true],
'organization_unit_image' => ['name' => 'organization_unit_image', 'type' => 'int', 'internal' => 'image'],
@ -49,7 +49,7 @@ final class UnitMapper extends DataMapperAbstract
* @var array<string, array{mapper:string, external:string, by?:string, column?:string, conditional?:bool}>
* @since 1.0.0
*/
protected static array $ownsOne = [
public const OWNS_ONE = [
'image' => [
'mapper' => MediaMapper::class,
'external' => 'organization_unit_image',
@ -62,7 +62,7 @@ final class UnitMapper extends DataMapperAbstract
* @var array<string, array{mapper:string, external:string}>
* @since 1.0.0
*/
protected static array $belongsTo = [
public const BELONGS_TO = [
'parent' => [
'mapper' => self::class,
'external' => 'organization_unit_parent',
@ -75,7 +75,7 @@ final class UnitMapper extends DataMapperAbstract
* @var string
* @since 1.0.0
*/
protected static string $model = Unit::class;
public const MODEL = Unit::class;
/**
* Primary table.
@ -83,7 +83,7 @@ final class UnitMapper extends DataMapperAbstract
* @var string
* @since 1.0.0
*/
protected static string $table = 'organization_unit';
public const TABLE = 'organization_unit';
/**
* Primary field name.
@ -91,5 +91,5 @@ final class UnitMapper extends DataMapperAbstract
* @var string
* @since 1.0.0
*/
protected static string $primaryField = 'organization_unit_id';
public const PRIMARYFIELD ='organization_unit_id';
}

View File

@ -12,7 +12,7 @@ require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/Autoloader.php';
use phpOMS\DataStorage\Database\DatabasePool;
use phpOMS\DataStorage\Database\DataMapperAbstract;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
use phpOMS\DataStorage\Session\HttpSession;
$CONFIG = [
@ -329,7 +329,7 @@ $GLOBALS['dbpool']->create('delete', $CONFIG['db']['core']['masters']['delete'])
$GLOBALS['dbpool']->create('insert', $CONFIG['db']['core']['masters']['insert']);
$GLOBALS['dbpool']->create('schema', $CONFIG['db']['core']['masters']['schema']);
DataMapperAbstract::setConnection($GLOBALS['dbpool']->get());
DataMapperFactory::db($GLOBALS['dbpool']->get());
$GLOBALS['frameworkpath'] = '/phpOMS/';

View File

@ -430,7 +430,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
]);
$this->module->apiUnitImageSet($request, $response);
$image = UnitMapper::get(1)->image;
$image = UnitMapper::get()->with('image')->where('id', 1)->execute()->image;
self::assertEquals('Organization Logo', $image->name);
}

View File

@ -35,9 +35,9 @@ final class DepartmentMapperTest extends \PHPUnit\Framework\TestCase
$department->description = 'Description';
$department->unit = new NullUnit(1);
$id = DepartmentMapper::create($department);
$id = DepartmentMapper::create()->execute($department);
$departmentR = DepartmentMapper::get($id);
$departmentR = DepartmentMapper::get()->where('id', $id)->execute();
self::assertEquals($id, $departmentR->getId());
self::assertEquals($department->name, $departmentR->name);
self::assertEquals($department->description, $departmentR->description);
@ -61,7 +61,7 @@ final class DepartmentMapperTest extends \PHPUnit\Framework\TestCase
$department->description = 'Description';
$department->parent = new NullDepartment($first);
$department->unit = new NullUnit(1);
DepartmentMapper::create($department);
DepartmentMapper::create()->execute($department);
/* 3 */
$department = new Department();
@ -69,7 +69,7 @@ final class DepartmentMapperTest extends \PHPUnit\Framework\TestCase
$department->description = 'Description';
$department->parent = new NullDepartment($first);
$department->unit = new NullUnit(1);
DepartmentMapper::create($department);
DepartmentMapper::create()->execute($department);
/* 4 */
$department = new Department();
@ -77,7 +77,7 @@ final class DepartmentMapperTest extends \PHPUnit\Framework\TestCase
$department->description = 'Description';
$department->parent = new NullDepartment($first);
$department->unit = new NullUnit(1);
DepartmentMapper::create($department);
DepartmentMapper::create()->execute($department);
/* 5 */
$department = new Department();
@ -85,7 +85,7 @@ final class DepartmentMapperTest extends \PHPUnit\Framework\TestCase
$department->description = 'Description';
$department->parent = new NullDepartment($first + 3);
$department->unit = new NullUnit(1);
DepartmentMapper::create($department);
DepartmentMapper::create()->execute($department);
/* 6 */
$department = new Department();
@ -93,7 +93,7 @@ final class DepartmentMapperTest extends \PHPUnit\Framework\TestCase
$department->description = 'Description';
$department->parent = new NullDepartment($first);
$department->unit = new NullUnit(1);
DepartmentMapper::create($department);
DepartmentMapper::create()->execute($department);
/* 7 */
$department = new Department();
@ -101,7 +101,7 @@ final class DepartmentMapperTest extends \PHPUnit\Framework\TestCase
$department->description = 'Description';
$department->parent = new NullDepartment($first + 5);
$department->unit = new NullUnit(1);
DepartmentMapper::create($department);
DepartmentMapper::create()->execute($department);
/* 8 */
$department = new Department();
@ -109,7 +109,7 @@ final class DepartmentMapperTest extends \PHPUnit\Framework\TestCase
$department->description = 'Description';
$department->parent = new NullDepartment($first);
$department->unit = new NullUnit(1);
DepartmentMapper::create($department);
DepartmentMapper::create()->execute($department);
/* 9 */
$department = new Department();
@ -117,6 +117,6 @@ final class DepartmentMapperTest extends \PHPUnit\Framework\TestCase
$department->description = 'Description';
$department->parent = new NullDepartment($first);
$department->unit = new NullUnit(1);
DepartmentMapper::create($department);
DepartmentMapper::create()->execute($department);
}
}

View File

@ -33,9 +33,9 @@ final class PositionMapperTest extends \PHPUnit\Framework\TestCase
$position->name = 'CEO';
$position->description = 'Description';
$id = PositionMapper::create($position);
$id = PositionMapper::create()->execute($position);
$positionR = PositionMapper::get($id);
$positionR = PositionMapper::get()->where('id', $id)->execute();
self::assertEquals($id, $positionR->getId());
self::assertEquals($position->name, $positionR->name);
self::assertEquals($position->description, $positionR->description);
@ -57,55 +57,55 @@ final class PositionMapperTest extends \PHPUnit\Framework\TestCase
$position->name = 'CFO';
$position->description = 'Description';
$position->parent = new NullPosition($first);
$id = PositionMapper::create($position);
$id = PositionMapper::create()->execute($position);
/* 5 */
$position = new Position();
$position->name = 'Accountant';
$position->description = 'Description';
$position->parent = new NullPosition($id);
PositionMapper::create($position);
PositionMapper::create()->execute($position);
/* 6 */
$position = new Position();
$position->name = 'Controller';
$position->description = 'Description';
$position->parent = new NullPosition($id);
PositionMapper::create($position);
PositionMapper::create()->execute($position);
/* 7 */
$position = new Position();
$position->name = 'Sales Director';
$position->description = 'Description';
$position->parent = new NullPosition($first);
PositionMapper::create($position);
PositionMapper::create()->execute($position);
/* 8 */
$position = new Position();
$position->name = 'Purchase Director';
$position->description = 'Description';
$position->parent = new NullPosition($first);
PositionMapper::create($position);
PositionMapper::create()->execute($position);
/* 9 */
$position = new Position();
$position->name = 'Territory Manager';
$position->description = 'Description';
$position->parent = new NullPosition($first + 4);
PositionMapper::create($position);
PositionMapper::create()->execute($position);
/* 10 */
$position = new Position();
$position->name = 'Territory Sales Assistant';
$position->description = 'Description';
$position->parent = new NullPosition($first + 6);
PositionMapper::create($position);
PositionMapper::create()->execute($position);
/* 11 */
$position = new Position();
$position->name = 'Domestic Sales Manager';
$position->description = 'Description';
$position->parent = new NullPosition($first + 4);
PositionMapper::create($position);
PositionMapper::create()->execute($position);
}
}

View File

@ -34,9 +34,9 @@ final class UnitMapperTest extends \PHPUnit\Framework\TestCase
$unit->description = 'Description';
$unit->parent = new NullUnit(1);
$id = UnitMapper::create($unit);
$id = UnitMapper::create()->execute($unit);
$unitR = UnitMapper::get($id);
$unitR = UnitMapper::get()->where('id', $id)->execute();
self::assertEquals($id, $unitR->getId());
self::assertEquals($unit->name, $unitR->name);
self::assertEquals($unit->description, $unitR->description);