mailgun-php/tests/Model/Domain/TrackingResponseTest.php

62 lines
1.9 KiB
PHP
Raw Normal View History

2020-10-10 00:43:27 +03:00
<?php
declare(strict_types=1);
/*
* Copyright (C) 2013 Mailgun
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
namespace Mailgun\Tests\Model\Domain;
use Mailgun\Model\Domain\ClickTracking;
use Mailgun\Model\Domain\OpenTracking;
use Mailgun\Model\Domain\TrackingResponse;
use Mailgun\Model\Domain\UnsubscribeTracking;
use Mailgun\Tests\Model\BaseModelTest;
class TrackingResponseTest extends BaseModelTest
{
public function testCreate()
{
$json =
<<<'JSON'
{
"tracking": {
"click": {
"active": "htmlonly"
2020-10-10 00:43:27 +03:00
},
"open": {
"active": "no"
2020-10-10 00:43:27 +03:00
},
"unsubscribe": {
"active": false,
2020-10-10 00:43:27 +03:00
"html_footer": "<s>Test<\/s>",
"text_footer": "Test"
}
}
}
JSON;
$model = TrackingResponse::create(json_decode($json, true));
$this->assertNotEmpty($model->getClick());
$this->assertInstanceOf(ClickTracking::class, $model->getClick());
$this->assertEquals('htmlonly', $model->getClick()->getActive());
$this->assertFalse($model->getClick()->isActive());
2020-10-12 20:44:37 +03:00
$this->assertTrue($model->getClick()->isHtmlOnly());
2020-10-10 00:43:27 +03:00
$this->assertNotEmpty($model->getOpen());
$this->assertInstanceOf(OpenTracking::class, $model->getOpen());
$this->assertEquals('no', $model->getOpen()->getActive());
$this->assertFalse($model->getOpen()->isActive());
2020-10-10 00:43:27 +03:00
$this->assertNotEmpty($model->getUnsubscribe());
$this->assertInstanceOf(UnsubscribeTracking::class, $model->getUnsubscribe());
$this->assertEquals('false', $model->getUnsubscribe()->getActive());
$this->assertFalse($model->getUnsubscribe()->isActive());
2020-10-10 00:43:27 +03:00
$this->assertEquals('<s>Test</s>', $model->getUnsubscribe()->getHtmlFooter());
$this->assertEquals('Test', $model->getUnsubscribe()->getTextFooter());
}
}