diff --git a/src/Application/Model/Configuration.php b/src/Application/Model/Configuration.php index 7b82141..d611e1c 100644 --- a/src/Application/Model/Configuration.php +++ b/src/Application/Model/Configuration.php @@ -20,6 +20,8 @@ use OxidEsales\Eshop\Core\Registry; class Configuration { + public const DEBUG = "d3linkmobility_debug"; + /** * @return string */ @@ -37,7 +39,7 @@ class Configuration */ public function getTestMode(): bool { - return (bool) Registry::getConfig()->getConfigParam('d3linkmobility_debug'); + return (bool) Registry::getConfig()->getConfigParam(self::DEBUG); } /** diff --git a/tests/Application/Controller/Admin/AdminOrderTest.php b/tests/Integration/Application/Controller/Admin/AdminOrderTest.php similarity index 92% rename from tests/Application/Controller/Admin/AdminOrderTest.php rename to tests/Integration/Application/Controller/Admin/AdminOrderTest.php index de2f539..9f0d4a2 100644 --- a/tests/Application/Controller/Admin/AdminOrderTest.php +++ b/tests/Integration/Application/Controller/Admin/AdminOrderTest.php @@ -13,7 +13,7 @@ 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\ModCfg\Tests\unit\d3ModCfgUnitTestCase; diff --git a/tests/Application/Model/MessageTypes/SmsTest.php b/tests/Integration/Application/Model/MessageTypes/SmsTest.php similarity index 69% rename from tests/Application/Model/MessageTypes/SmsTest.php rename to tests/Integration/Application/Model/MessageTypes/SmsTest.php index 4a27f59..fe44959 100644 --- a/tests/Application/Model/MessageTypes/SmsTest.php +++ b/tests/Integration/Application/Model/MessageTypes/SmsTest.php @@ -13,8 +13,9 @@ 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\ModCfg\Tests\unit\d3ModCfgUnitTestCase; use libphonenumber\PhoneNumberFormat; @@ -22,6 +23,9 @@ use libphonenumber\PhoneNumberType; use libphonenumber\PhoneNumberUtil; use OxidEsales\Eshop\Application\Model\Country; 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 ReflectionException; @@ -30,6 +34,7 @@ class SmsTest extends d3ModCfgUnitTestCase /** @var Sms */ protected $model; protected $countryId = 'countryIdNo1'; + protected $userId = 'userIdNo1'; protected $exampleNumber; public function setUp() @@ -38,6 +43,15 @@ class SmsTest extends d3ModCfgUnitTestCase $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->setId($this->countryId); $country->assign([ @@ -45,19 +59,27 @@ class SmsTest extends d3ModCfgUnitTestCase ]); $country->save(); - $phoneUtil = PhoneNumberUtil::getInstance(); - $example = $phoneUtil->getExampleNumberForType('DE', PhoneNumberType::MOBILE); - $this->exampleNumber = $phoneUtil->format($example, PhoneNumberFormat::NATIONAL); + //$user = new User(); + //$user->setId($this->userId); + //$user->save(); } public function tearDown() { parent::tearDown(); + $this->clearObjects(); + + unset($this->model); + } + + public function clearObjects() + { $country = oxNew(Country::class); $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() { + Registry::getConfig()->setConfigParam(Configuration::DEBUG, true); + + /** @var User $user */ + //$user = oxNew(User::class); + //$user->load($this->userId); + /** @var Order|MockObject $orderMock */ $orderMock = $this->getMockBuilder(Order::class) - ->setMethods(['getFieldData']) + ->setMethods([ + 'getFieldData', + 'getOrderUser' + ]) ->disableOriginalConstructor() ->getMock(); $orderMock->method('getFieldData')->willReturnCallback([$this, 'orderFieldDataCallback']); + $orderMock->method('getOrderUser')->willReturn($user); $this->assertTrue( $this->callMethod( @@ -81,6 +113,13 @@ class SmsTest extends d3ModCfgUnitTestCase [$orderMock] ) ); + + $remark = oxNew(Remark::class); +dumpvar($remark); + // $remarkId = "SELECT oxid FROM ".$remark->getViewName()." WHERE " + // $this->assertTrue( + + // ) } public function orderFieldDataCallback()