Files
piratepoet/tests/unit/Newsletter/AutomatedLatestContentTest.php
Pavel Dohnal b80683a9a1 Fix unit tests for PHPUnit v6
Codeception from version 2.3 up comes with PHPUnit v6 which changed
__construct behaviour. Our tests have to call parent __constructor in
order to work. The error was:
[PHPUnit\Framework\Exception] array_merge(): Argument #1 is not an array
2017-06-07 11:32:33 +01:00

65 lines
1.4 KiB
PHP

<?php
use MailPoet\Newsletter\AutomatedLatestContent;
class AutomatedLatestContentTest extends MailPoetTest {
function __construct() {
parent::__construct();
$this->alc = new AutomatedLatestContent();
}
function testItCategorizesTermsToTaxonomies() {
$args = array(
'terms' => array(
array(
'id' => 1,
'taxonomy' => 'post_tag'
),
array(
'id' => 2,
'taxonomy' => 'product_tag',
),
array(
'id' => 3,
'taxonomy' => 'post_tag'
)
),
'inclusionType' => 'include',
);
expect($this->alc->constructTaxonomiesQuery($args))->equals(array(
array(
'taxonomy' => 'post_tag',
'field' => 'id',
'terms' => array(1, 3)
),
array(
'taxonomy' => 'product_tag',
'field' => 'id',
'terms' => array(2)
),
'relation' => 'OR'
));
}
function testItCanExcludeTaxonomies() {
$args = array(
'terms' => array(
array(
'id' => 7,
'taxonomy' => 'post_tag'
),
array(
'id' => 8,
'taxonomy' => 'post_tag'
)
),
'inclusionType' => 'exclude',
);
$query = $this->alc->constructTaxonomiesQuery($args);
expect($query[0]['operator'])->equals('NOT IN');
expect($query['relation'])->equals('AND');
}
}