change sms tests
This commit is contained in:
parent
81b7fab1c1
commit
524a2bd57f
|
@ -20,6 +20,8 @@ use OxidEsales\Eshop\Core\Registry;
|
||||||
|
|
||||||
class Configuration
|
class Configuration
|
||||||
{
|
{
|
||||||
|
public const DEBUG = "d3linkmobility_debug";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
@ -37,7 +39,7 @@ class Configuration
|
||||||
*/
|
*/
|
||||||
public function getTestMode(): bool
|
public function getTestMode(): bool
|
||||||
{
|
{
|
||||||
return (bool) Registry::getConfig()->getConfigParam('d3linkmobility_debug');
|
return (bool) Registry::getConfig()->getConfigParam(self::DEBUG);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace D3\Linkmobility4OXID\Tests\Application\Controller\Admin;
|
namespace D3\Linkmobility4OXID\Tests\Integration\Application\Controller\Admin;
|
||||||
|
|
||||||
use D3\Linkmobility4OXID\Application\Controller\Admin\AdminOrder;
|
use D3\Linkmobility4OXID\Application\Controller\Admin\AdminOrder;
|
||||||
use D3\ModCfg\Tests\unit\d3ModCfgUnitTestCase;
|
use D3\ModCfg\Tests\unit\d3ModCfgUnitTestCase;
|
|
@ -13,8 +13,9 @@
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace D3\Linkmobility4OXID\Tests\Application\Model\MessageTypes;
|
namespace D3\Linkmobility4OXID\Tests\Integration\Application\Model\MessageTypes;
|
||||||
|
|
||||||
|
use D3\Linkmobility4OXID\Application\Model\Configuration;
|
||||||
use D3\Linkmobility4OXID\Application\Model\MessageTypes\Sms;
|
use D3\Linkmobility4OXID\Application\Model\MessageTypes\Sms;
|
||||||
use D3\ModCfg\Tests\unit\d3ModCfgUnitTestCase;
|
use D3\ModCfg\Tests\unit\d3ModCfgUnitTestCase;
|
||||||
use libphonenumber\PhoneNumberFormat;
|
use libphonenumber\PhoneNumberFormat;
|
||||||
|
@ -22,6 +23,9 @@ use libphonenumber\PhoneNumberType;
|
||||||
use libphonenumber\PhoneNumberUtil;
|
use libphonenumber\PhoneNumberUtil;
|
||||||
use OxidEsales\Eshop\Application\Model\Country;
|
use OxidEsales\Eshop\Application\Model\Country;
|
||||||
use OxidEsales\Eshop\Application\Model\Order;
|
use OxidEsales\Eshop\Application\Model\Order;
|
||||||
|
use OxidEsales\Eshop\Application\Model\Remark;
|
||||||
|
use OxidEsales\Eshop\Core\Registry;
|
||||||
|
use OxidEsales\PayPalModule\Model\User;
|
||||||
use PHPUnit\Framework\MockObject\MockObject;
|
use PHPUnit\Framework\MockObject\MockObject;
|
||||||
use ReflectionException;
|
use ReflectionException;
|
||||||
|
|
||||||
|
@ -30,6 +34,7 @@ class SmsTest extends d3ModCfgUnitTestCase
|
||||||
/** @var Sms */
|
/** @var Sms */
|
||||||
protected $model;
|
protected $model;
|
||||||
protected $countryId = 'countryIdNo1';
|
protected $countryId = 'countryIdNo1';
|
||||||
|
protected $userId = 'userIdNo1';
|
||||||
protected $exampleNumber;
|
protected $exampleNumber;
|
||||||
|
|
||||||
public function setUp()
|
public function setUp()
|
||||||
|
@ -38,6 +43,15 @@ class SmsTest extends d3ModCfgUnitTestCase
|
||||||
|
|
||||||
$this->model = oxNew(Sms::class, 'demomessage');
|
$this->model = oxNew(Sms::class, 'demomessage');
|
||||||
|
|
||||||
|
$this->addObjects();
|
||||||
|
|
||||||
|
$phoneUtil = PhoneNumberUtil::getInstance();
|
||||||
|
$example = $phoneUtil->getExampleNumberForType('DE', PhoneNumberType::MOBILE);
|
||||||
|
$this->exampleNumber = $phoneUtil->format($example, PhoneNumberFormat::NATIONAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addObjects()
|
||||||
|
{
|
||||||
$country = oxNew(Country::class);
|
$country = oxNew(Country::class);
|
||||||
$country->setId($this->countryId);
|
$country->setId($this->countryId);
|
||||||
$country->assign([
|
$country->assign([
|
||||||
|
@ -45,19 +59,27 @@ class SmsTest extends d3ModCfgUnitTestCase
|
||||||
]);
|
]);
|
||||||
$country->save();
|
$country->save();
|
||||||
|
|
||||||
$phoneUtil = PhoneNumberUtil::getInstance();
|
//$user = new User();
|
||||||
$example = $phoneUtil->getExampleNumberForType('DE', PhoneNumberType::MOBILE);
|
//$user->setId($this->userId);
|
||||||
$this->exampleNumber = $phoneUtil->format($example, PhoneNumberFormat::NATIONAL);
|
//$user->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tearDown()
|
public function tearDown()
|
||||||
{
|
{
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
|
|
||||||
|
$this->clearObjects();
|
||||||
|
|
||||||
|
unset($this->model);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function clearObjects()
|
||||||
|
{
|
||||||
$country = oxNew(Country::class);
|
$country = oxNew(Country::class);
|
||||||
$country->delete($this->countryId);
|
$country->delete($this->countryId);
|
||||||
|
|
||||||
unset($this->model);
|
$user = oxNew(User::class);
|
||||||
|
$user->delete($this->userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,12 +89,22 @@ class SmsTest extends d3ModCfgUnitTestCase
|
||||||
*/
|
*/
|
||||||
public function testSendOrderMessage()
|
public function testSendOrderMessage()
|
||||||
{
|
{
|
||||||
|
Registry::getConfig()->setConfigParam(Configuration::DEBUG, true);
|
||||||
|
|
||||||
|
/** @var User $user */
|
||||||
|
//$user = oxNew(User::class);
|
||||||
|
//$user->load($this->userId);
|
||||||
|
|
||||||
/** @var Order|MockObject $orderMock */
|
/** @var Order|MockObject $orderMock */
|
||||||
$orderMock = $this->getMockBuilder(Order::class)
|
$orderMock = $this->getMockBuilder(Order::class)
|
||||||
->setMethods(['getFieldData'])
|
->setMethods([
|
||||||
|
'getFieldData',
|
||||||
|
'getOrderUser'
|
||||||
|
])
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
$orderMock->method('getFieldData')->willReturnCallback([$this, 'orderFieldDataCallback']);
|
$orderMock->method('getFieldData')->willReturnCallback([$this, 'orderFieldDataCallback']);
|
||||||
|
$orderMock->method('getOrderUser')->willReturn($user);
|
||||||
|
|
||||||
$this->assertTrue(
|
$this->assertTrue(
|
||||||
$this->callMethod(
|
$this->callMethod(
|
||||||
|
@ -81,6 +113,13 @@ class SmsTest extends d3ModCfgUnitTestCase
|
||||||
[$orderMock]
|
[$orderMock]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$remark = oxNew(Remark::class);
|
||||||
|
dumpvar($remark);
|
||||||
|
// $remarkId = "SELECT oxid FROM ".$remark->getViewName()." WHERE "
|
||||||
|
// $this->assertTrue(
|
||||||
|
|
||||||
|
// )
|
||||||
}
|
}
|
||||||
|
|
||||||
public function orderFieldDataCallback()
|
public function orderFieldDataCallback()
|
Loading…
Reference in New Issue