mirror of
https://github.com/Karaka-Management/oms-Profile.git
synced 2026-02-14 22:48:39 +00:00
PhpUnit fixes
This commit is contained in:
parent
a9aedcac02
commit
6e89554fd8
|
|
@ -46,11 +46,10 @@ class Installer extends InstallerAbstract
|
||||||
case DatabaseType::MYSQL:
|
case DatabaseType::MYSQL:
|
||||||
$dbPool->get('core')->con->prepare(
|
$dbPool->get('core')->con->prepare(
|
||||||
'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'profile_account` (
|
'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'profile_account` (
|
||||||
`profile_account_id` int(11) NOT NULL,
|
`profile_account_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
`profile_account_begin` datetime NOT NULL,
|
`profile_account_image` int(11) DEFAULT NULL,
|
||||||
`profile_account_image` int(11) NOT NULL,
|
`profile_account_birthday` datetime DEFAULT NULL,
|
||||||
`profile_account_birthday` datetime NOT NULL,
|
`profile_account_account` int(11) NOT NULL,
|
||||||
`profile_account_account` int(11) DEFAULT NULL,
|
|
||||||
PRIMARY KEY (`profile_account_id`),
|
PRIMARY KEY (`profile_account_id`),
|
||||||
KEY `profile_account_image` (`profile_account_image`),
|
KEY `profile_account_image` (`profile_account_image`),
|
||||||
KEY `profile_account_account` (`profile_account_account`)
|
KEY `profile_account_account` (`profile_account_account`)
|
||||||
|
|
@ -66,7 +65,7 @@ class Installer extends InstallerAbstract
|
||||||
// real contacts that you also save in your email contact list. this is to store other accounts
|
// real contacts that you also save in your email contact list. this is to store other accounts
|
||||||
$dbPool->get('core')->con->prepare(
|
$dbPool->get('core')->con->prepare(
|
||||||
'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'profile_contact` (
|
'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'profile_contact` (
|
||||||
`profile_contact_id` int(11) NOT NULL,
|
`profile_contact_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
`profile_contact_name1` varchar(250) NOT NULL,
|
`profile_contact_name1` varchar(250) NOT NULL,
|
||||||
`profile_contact_name2` varchar(250) NOT NULL,
|
`profile_contact_name2` varchar(250) NOT NULL,
|
||||||
`profile_contact_name3` varchar(250) NOT NULL,
|
`profile_contact_name3` varchar(250) NOT NULL,
|
||||||
|
|
@ -87,27 +86,28 @@ class Installer extends InstallerAbstract
|
||||||
ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'profile_contact_ibfk_1` FOREIGN KEY (`profile_contact_account`) REFERENCES `' . $dbPool->get('core')->prefix . 'profile_account` (`profile_account_id`);'
|
ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'profile_contact_ibfk_1` FOREIGN KEY (`profile_contact_account`) REFERENCES `' . $dbPool->get('core')->prefix . 'profile_account` (`profile_account_id`);'
|
||||||
)->execute();
|
)->execute();
|
||||||
|
|
||||||
|
// email, phone etc for profile_contact
|
||||||
$dbPool->get('core')->con->prepare(
|
$dbPool->get('core')->con->prepare(
|
||||||
'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'profile_contact_element` (
|
'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'profile_contact_element` (
|
||||||
`profile_contact_element_id` int(11) NOT NULL,
|
`profile_contact_element_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
`profile_contact_element_type` tinyint(2) NOT NULL,
|
`profile_contact_element_type` tinyint(2) NOT NULL,
|
||||||
`profile_contact_element_subtype` tinyint(2) NOT NULL,
|
`profile_contact_element_subtype` tinyint(2) NOT NULL,
|
||||||
`profile_contact_element_content` varchar(50) NOT NULL,
|
`profile_contact_element_content` varchar(50) NOT NULL,
|
||||||
`profile_contact_element_contact` int(11) NOT NULL,
|
`profile_contact_element_contact` int(11) NOT NULL,
|
||||||
PRIMARY KEY (`profile_contact_element_id`),
|
PRIMARY KEY (`profile_contact_element_id`),
|
||||||
KEY `profile_contact_element_account` (`profile_contact_element_account`)
|
KEY `profile_contact_element_contact` (`profile_contact_element_contact`)
|
||||||
)ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
|
)ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
|
||||||
)->execute();
|
)->execute();
|
||||||
|
|
||||||
$dbPool->get('core')->con->prepare(
|
$dbPool->get('core')->con->prepare(
|
||||||
'ALTER TABLE `' . $dbPool->get('core')->prefix . 'profile_contact_element`
|
'ALTER TABLE `' . $dbPool->get('core')->prefix . 'profile_contact_element`
|
||||||
ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'profile_contact_element_ibfk_1` FOREIGN KEY (`profile_contact_element_account`) REFERENCES `' . $dbPool->get('core')->prefix . 'profile_contact` (`profile_contact_id`);'
|
ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'profile_contact_element_ibfk_1` FOREIGN KEY (`profile_contact_element_contact`) REFERENCES `' . $dbPool->get('core')->prefix . 'profile_contact` (`profile_contact_id`);'
|
||||||
)->execute();
|
)->execute();
|
||||||
|
|
||||||
// not a full contact only the element like email, phone etc. for the accounts themselves
|
// not a full contact only the element like email, phone etc. for the accounts themselves (not profile_account)
|
||||||
$dbPool->get('core')->con->prepare(
|
$dbPool->get('core')->con->prepare(
|
||||||
'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'profile_contactelement` (
|
'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'profile_contactelement` (
|
||||||
`profile_contactelement_id` int(11) NOT NULL,
|
`profile_contactelement_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
`profile_contactelement_type` tinyint(2) NOT NULL,
|
`profile_contactelement_type` tinyint(2) NOT NULL,
|
||||||
`profile_contactelement_subtype` tinyint(2) NOT NULL,
|
`profile_contactelement_subtype` tinyint(2) NOT NULL,
|
||||||
`profile_contactelement_content` varchar(50) NOT NULL,
|
`profile_contactelement_content` varchar(50) NOT NULL,
|
||||||
|
|
@ -124,7 +124,7 @@ class Installer extends InstallerAbstract
|
||||||
|
|
||||||
$dbPool->get('core')->con->prepare(
|
$dbPool->get('core')->con->prepare(
|
||||||
'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'profile_address` (
|
'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'profile_address` (
|
||||||
`profile_address_id` int(11) NOT NULL,
|
`profile_address_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
`profile_address_type` tinyint(2) NOT NULL,
|
`profile_address_type` tinyint(2) NOT NULL,
|
||||||
`profile_address_address` varchar(50) NOT NULL,
|
`profile_address_address` varchar(50) NOT NULL,
|
||||||
`profile_address_street` varchar(50) NOT NULL,
|
`profile_address_street` varchar(50) NOT NULL,
|
||||||
|
|
@ -139,12 +139,12 @@ class Installer extends InstallerAbstract
|
||||||
|
|
||||||
$dbPool->get('core')->con->prepare(
|
$dbPool->get('core')->con->prepare(
|
||||||
'ALTER TABLE `' . $dbPool->get('core')->prefix . 'profile_address`
|
'ALTER TABLE `' . $dbPool->get('core')->prefix . 'profile_address`
|
||||||
ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'profile_address_ibfk_1` FOREIGN KEY (`profile_address_account`) REFERENCES `' . $dbPool->get('core')->prefix . 'account` (`account_id`);'
|
ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'profile_address_ibfk_1` FOREIGN KEY (`profile_address_account`) REFERENCES `' . $dbPool->get('core')->prefix . 'profile_account` (`profile_account_id`);'
|
||||||
)->execute();
|
)->execute();
|
||||||
|
|
||||||
$dbPool->get('core')->con->prepare(
|
$dbPool->get('core')->con->prepare(
|
||||||
'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'profile_account_relation` (
|
'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'profile_account_relation` (
|
||||||
`profile_account_relation_id` int(11) NOT NULL,
|
`profile_account_relation_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
`profile_account_relation_type` tinyint(2) NOT NULL,
|
`profile_account_relation_type` tinyint(2) NOT NULL,
|
||||||
`profile_account_relation_relation` int(11) DEFAULT NULL,
|
`profile_account_relation_relation` int(11) DEFAULT NULL,
|
||||||
`profile_account_relation_account` int(11) DEFAULT NULL,
|
`profile_account_relation_account` int(11) DEFAULT NULL,
|
||||||
|
|
@ -160,7 +160,7 @@ class Installer extends InstallerAbstract
|
||||||
|
|
||||||
$dbPool->get('core')->con->prepare(
|
$dbPool->get('core')->con->prepare(
|
||||||
'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'profile_account_setting` (
|
'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'profile_account_setting` (
|
||||||
`profile_account_setting_id` int(11) NOT NULL,
|
`profile_account_setting_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
`profile_account_setting_module` int(11) NOT NULL,
|
`profile_account_setting_module` int(11) NOT NULL,
|
||||||
`profile_account_setting_type` varchar(20) NOT NULL,
|
`profile_account_setting_type` varchar(20) NOT NULL,
|
||||||
`profile_account_setting_value` varchar(32) DEFAULT NULL,
|
`profile_account_setting_value` varchar(32) DEFAULT NULL,
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,11 @@ class ContactElementMapper extends DataMapperAbstract
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$objId = parent::create($obj, $relations);
|
$objId = parent::create($obj, $relations);
|
||||||
|
|
||||||
|
if($objId === null || !is_scalar($objId)) {
|
||||||
|
return $objId;
|
||||||
|
}
|
||||||
|
|
||||||
$query = new Builder(self::$db);
|
$query = new Builder(self::$db);
|
||||||
|
|
||||||
$query->prefix(self::$db->getPrefix())
|
$query->prefix(self::$db->getPrefix())
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ declare(strict_types=1);
|
||||||
namespace Modules\Profile\Models;
|
namespace Modules\Profile\Models;
|
||||||
|
|
||||||
use Modules\Admin\Models\Account;
|
use Modules\Admin\Models\Account;
|
||||||
|
use Modules\Media\Models\Media;
|
||||||
use Modules\Media\Models\NullMedia;
|
use Modules\Media\Models\NullMedia;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -43,7 +44,7 @@ class Profile
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->image = new NullMedia();
|
$this->image = new NullMedia();
|
||||||
$this->birthday = new \DateTime();
|
$this->birthday = new \DateTime('now');
|
||||||
$this->account = new Account();
|
$this->account = new Account();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -71,4 +72,14 @@ class Profile
|
||||||
{
|
{
|
||||||
return $this->account;
|
return $this->account;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setBirthday(\DateTime $birthday) /* : void */
|
||||||
|
{
|
||||||
|
$this->birthday = $birthday;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBirthday() : \DateTime
|
||||||
|
{
|
||||||
|
return $this->birthday;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,8 @@ use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||||
use phpOMS\DataStorage\Database\Query\Builder;
|
use phpOMS\DataStorage\Database\Query\Builder;
|
||||||
use phpOMS\DataStorage\Database\Query\Column;
|
use phpOMS\DataStorage\Database\Query\Column;
|
||||||
use phpOMS\DataStorage\Database\RelationType;
|
use phpOMS\DataStorage\Database\RelationType;
|
||||||
use Modules\Admin\Account;
|
use Modules\Admin\Models\Account;
|
||||||
|
use Modules\Admin\Models\AccountMapper;
|
||||||
|
|
||||||
class ProfileMapper extends DataMapperAbstract
|
class ProfileMapper extends DataMapperAbstract
|
||||||
{
|
{
|
||||||
|
|
@ -34,7 +35,8 @@ class ProfileMapper extends DataMapperAbstract
|
||||||
protected static $columns = [
|
protected static $columns = [
|
||||||
'profile_account_id' => ['name' => 'profile_account_id', 'type' => 'int', 'internal' => 'id'],
|
'profile_account_id' => ['name' => 'profile_account_id', 'type' => 'int', 'internal' => 'id'],
|
||||||
'profile_account_image' => ['name' => 'profile_account_image', 'type' => 'int', 'internal' => 'image'],
|
'profile_account_image' => ['name' => 'profile_account_image', 'type' => 'int', 'internal' => 'image'],
|
||||||
'profile_account_birthday' => ['name' => 'profile_account_birthday', 'type' => '\DateTime', 'internal' => 'birthday'],
|
'profile_account_birthday' => ['name' => 'profile_account_birthday', 'type' => 'DateTime', 'internal' => 'birthday'],
|
||||||
|
'profile_account_account' => ['name' => 'profile_account_account', 'type' => 'int', 'internal' => 'account'],
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -44,7 +46,7 @@ class ProfileMapper extends DataMapperAbstract
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected static $ownsOne = [
|
protected static $ownsOne = [
|
||||||
'profile' => [
|
'account' => [
|
||||||
'mapper' => AccountMapper::class,
|
'mapper' => AccountMapper::class,
|
||||||
'src' => 'profile_account_account',
|
'src' => 'profile_account_account',
|
||||||
],
|
],
|
||||||
|
|
@ -60,7 +62,7 @@ class ProfileMapper extends DataMapperAbstract
|
||||||
* @var string
|
* @var string
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected static $table = 'profile';
|
protected static $table = 'profile_account';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Primary field name.
|
* Primary field name.
|
||||||
|
|
@ -68,7 +70,7 @@ class ProfileMapper extends DataMapperAbstract
|
||||||
* @var string
|
* @var string
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected static $primaryField = 'profile_id';
|
protected static $primaryField = 'profile_account_id';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create object.
|
* Create object.
|
||||||
|
|
@ -85,6 +87,11 @@ class ProfileMapper extends DataMapperAbstract
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$objId = parent::create($obj, $relations);
|
$objId = parent::create($obj, $relations);
|
||||||
|
|
||||||
|
if($objId === null || !is_scalar($objId)) {
|
||||||
|
return $objId;
|
||||||
|
}
|
||||||
|
|
||||||
$query = new Builder(self::$db);
|
$query = new Builder(self::$db);
|
||||||
|
|
||||||
$query->prefix(self::$db->getPrefix())
|
$query->prefix(self::$db->getPrefix())
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,8 @@
|
||||||
"description": "The profile module.",
|
"description": "The profile module.",
|
||||||
"directory": "Profile",
|
"directory": "Profile",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"Admin" : "1.0.0"
|
"Admin" : "1.0.0",
|
||||||
|
"Media" : "1.0.0"
|
||||||
},
|
},
|
||||||
"providing": {
|
"providing": {
|
||||||
"Navigation": "*"
|
"Navigation": "*"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user