-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
finalize tests, update readme and changelog
- Loading branch information
1 parent
f54cdfc
commit 2a36edb
Showing
5 changed files
with
126 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,11 @@ | |
|
||
namespace PaBlo\MultiOrderMailReceiver\Test\Unit\Core; | ||
|
||
use OxidEsales\Eshop\Application\Model\Order; | ||
use OxidEsales\Eshop\Application\Model\Shop; | ||
use OxidEsales\Eshop\Core\Field; | ||
use OxidEsales\Eshop\Core\Price; | ||
use OxidEsales\Eshop\Application\Model\User; | ||
use OxidEsales\TestingLibrary\UnitTestCase; | ||
use PaBlo\MultiOrderMailReceiver\Core\Email; | ||
|
||
|
@@ -29,7 +33,7 @@ public function setUp() | |
parent::setUp(); | ||
|
||
$this->SUT = $this->getMockBuilder(Email::class) | ||
->setMethods(['__call', 'send', 'getRenderer']) | ||
->setMethods(['__call', '_sendMail']) | ||
->getMock(); | ||
} | ||
|
||
|
@@ -83,7 +87,6 @@ public function testSetCarbonCopy_withValidData(): void | |
$this->assertSame('Max Muster', $carbonCopies[0][1]); | ||
} | ||
|
||
|
||
/** | ||
* @covers \PaBlo\MultiOrderMailReceiver\Core\Email::setCarbonCopy | ||
* @covers \PaBlo\MultiOrderMailReceiver\Core\Email::idnToAscii | ||
|
@@ -124,7 +127,6 @@ public function testSetCarbonCopyActive_willSetInternalStateTrue(): void | |
$this->assertTrue($internalState); | ||
} | ||
|
||
|
||
/** | ||
* @covers \PaBlo\MultiOrderMailReceiver\Core\Email::getCarbonCopyActiveState | ||
*/ | ||
|
@@ -176,7 +178,7 @@ public function testSetFrom_willAddCarbonCopyEntries(): void | |
{ | ||
// add demo carbon copies | ||
/** @var Shop $shop */ | ||
$shop = $this->getConfig()->getActiveShop(); | ||
$shop = $this->getConfig()->getActiveShop(); | ||
$shop->oxshops__pbowneremailreceiver->rawValue = '[email protected];NOEMAILADDRESS;[email protected]'; | ||
$shop->save(); | ||
|
||
|
@@ -190,12 +192,67 @@ public function testSetFrom_willAddCarbonCopyEntries(): void | |
$this->assertTrue($result); | ||
|
||
$carbonCopies = $this->SUT->getCarbonCopy(); | ||
|
||
$this->assertNotEmpty($carbonCopies); | ||
$this->assertCount(2, $carbonCopies); | ||
$this->assertSame('[email protected]',$carbonCopies[0][0]); | ||
$this->assertSame('[email protected]',$carbonCopies[1][0]); | ||
$this->assertSame('order',$carbonCopies[0][1]); | ||
$this->assertSame('order',$carbonCopies[1][1]); | ||
$this->assertSame('[email protected]', $carbonCopies[0][0]); | ||
$this->assertSame('[email protected]', $carbonCopies[1][0]); | ||
$this->assertSame('order', $carbonCopies[0][1]); | ||
$this->assertSame('order', $carbonCopies[1][1]); | ||
|
||
} | ||
|
||
/** | ||
* @covers \PaBlo\MultiOrderMailReceiver\Core\Email::sendOrderEmailToOwner | ||
*/ | ||
public function testSendOrderEMailToOwner_willSetCarbonCopyActive(): void | ||
{ | ||
$internalState = $this->getProtectedClassProperty($this->SUT, '_blCarbonCopyActiveState'); | ||
$this->assertFalse($internalState); | ||
|
||
$payment = oxNew('oxPayment'); | ||
$payment->oxpayments__oxdesc = new Field("testPaymentDesc"); | ||
|
||
$basket = oxNew('oxBasket'); | ||
$basket->setCost('oxpayment', new Price(0)); | ||
$basket->setCost('oxdelivery', new Price(6626)); | ||
|
||
$user = oxNew(User::class); | ||
$user->setId('_testUserId'); | ||
$user->oxuser__oxactive = new Field('1', Field::T_RAW); | ||
$user->oxuser__oxusername = new Field('[email protected]', Field::T_RAW); | ||
$user->oxuser__oxcustnr = new Field('998', Field::T_RAW); | ||
$user->oxuser__oxfname = new Field('Patrick', Field::T_RAW); | ||
$user->oxuser__oxlname = new Field('Blom', Field::T_RAW); | ||
$user->oxuser__oxpassword = new Field('ox_BBpaRCslUU8u', Field::T_RAW); //pass = admin | ||
$user->oxuser__oxregister = new Field(date("Y-m-d H:i:s"), Field::T_RAW); | ||
|
||
$order = $this->getMockBuilder(Order::class) | ||
->setMethods(['getOrderUser', 'getBasket', 'getPayment', 'getDelSet']) | ||
->getMock(); | ||
$order->oxorder__oxbillcompany = new Field(''); | ||
$order->oxorder__oxbillfname = new Field(''); | ||
$order->oxorder__oxbilllname = new Field(''); | ||
$order->oxorder__oxbilladdinfo = new Field(''); | ||
$order->oxorder__oxbillstreet = new Field(''); | ||
$order->oxorder__oxbillcity = new Field(''); | ||
$order->oxorder__oxbillcountry = new Field(''); | ||
$order->oxorder__oxdeltype = new Field('oxidstandard'); | ||
|
||
$order->expects($this->any())->method('getOrderUser')->willReturn($user); | ||
$order->expects($this->any())->method('getBasket')->willReturn($basket); | ||
$order->expects($this->any())->method('getPayment')->willReturn($payment); | ||
|
||
$delSet = oxNew(\OxidEsales\Eshop\Application\Model\DeliverySet::class); | ||
$delSet->load($order->oxorder__oxdeltype->value); | ||
$order->expects($this->any())->method('getDelSet')->willReturn($delSet); | ||
|
||
$this->SUT->expects($this->once())->method('_sendMail')->willReturn(true); | ||
|
||
$blRet = $this->SUT->sendOrderEmailToOwner($order); | ||
$this->assertTrue($blRet); | ||
|
||
$internalState = $this->getProtectedClassProperty($this->SUT, '_blCarbonCopyActiveState'); | ||
$this->assertTrue($internalState); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
error_reporting(E_ALL & ~E_STRICT & ~E_DEPRECATED & ~E_WARNING & ~E_NOTICE); | ||
$this->dbName = 'oxid_test'; // database name | ||
$this->sShopDir = __DIR__; | ||
$this->sCompileDir = $this->sShopDir . '/tmp'; | ||
|
||
$this->iUtfMode = 0; | ||
|
||
$this->iDebug = 1; | ||
|
||
$this->blSkipViewUsage = true; |