* @link https://www.oxidmodule.com */ declare(strict_types=1); namespace D3\Linkmobility4OXID\Tests\Application\Model; use D3\Linkmobility4OXID\Application\Controller\Admin\AdminOrder; use D3\Linkmobility4OXID\Application\Model\Sms; use D3\ModCfg\Tests\unit\d3ModCfgUnitTestCase; use OxidEsales\Eshop\Application\Model\Country; use OxidEsales\Eshop\Application\Model\Order; use PHPUnit\Framework\MockObject\MockObject; use ReflectionException; class SmsTest extends d3ModCfgUnitTestCase { /** @var Sms */ protected $model; protected $countryId = 'countryIdNo1'; public function setUp() { parent::setUp(); $this->model = oxNew(Sms::class, 'demomessage'); $country = oxNew(Country::class); $country->setId($this->countryId); $country->assign([ 'oxisoalpha2' => 'DE' ]); $country->save(); } public function tearDown() { parent::tearDown(); $country = oxNew(Country::class); $country->delete($this->countryId); unset($this->model); } /** * @test * @return void * @throws ReflectionException */ public function testSendOrderMessage() { /** @var Order|MockObject $orderMock */ $orderMock = $this->getMockBuilder(Order::class) ->setMethods(['getFieldData']) ->disableOriginalConstructor() ->getMock(); $orderMock->method('getFieldData')->willReturnCallback([$this, 'orderFieldDataCallback']); $this->assertTrue( $this->callMethod( $this->model, 'sendOrderMessage', [$orderMock] ) ); } public function orderFieldDataCallback() { $aArgs = func_get_args(); switch ($aArgs[0]) { case 'oxdelfon': return '015792300219'; case 'oxdelcountryid': return $this->countryId; case 'oxbillfon': return '015792300219'; } $this->fail('Unknown variable '.$aArgs[0]); } }