2017-11-04 00:32:39 +00:00
|
|
|
<?php
|
|
|
|
|
2018-06-01 18:15:21 +00:00
|
|
|
use Opdavies\GmailFilterBuilder\Model\Filter;
|
|
|
|
use Opdavies\GmailFilterBuilder\Service\Builder;
|
2017-11-28 07:09:17 +00:00
|
|
|
use PHPUnit\Framework\TestCase;
|
2017-11-04 00:32:39 +00:00
|
|
|
|
2017-11-28 07:09:17 +00:00
|
|
|
class BuilderTest extends TestCase
|
2017-11-04 00:32:39 +00:00
|
|
|
{
|
|
|
|
public function testBuild()
|
|
|
|
{
|
2017-12-30 10:28:19 +00:00
|
|
|
$filterA = (new Filter())
|
2017-12-30 10:49:31 +00:00
|
|
|
->from(['foo@example.com', 'test@example.com'])
|
2017-12-30 10:28:19 +00:00
|
|
|
->label('Some label')
|
|
|
|
->archive();
|
2017-11-04 00:32:39 +00:00
|
|
|
|
2017-12-30 10:28:19 +00:00
|
|
|
$filterB = (new Filter())
|
|
|
|
->has('from:bar@example.com')
|
|
|
|
->star()
|
|
|
|
->important();
|
2017-11-04 00:32:39 +00:00
|
|
|
|
2018-01-15 09:24:38 +00:00
|
|
|
$result = new Builder([$filterA, $filterB], '', false);
|
2017-12-30 10:28:19 +00:00
|
|
|
|
2018-01-04 23:22:23 +00:00
|
|
|
$expected = <<<EOF
|
2018-01-05 00:55:22 +00:00
|
|
|
<?xml version='1.0' encoding='UTF-8'?>
|
|
|
|
<feed xmlns='http://www.w3.org/2005/Atom' xmlns:apps='http://schemas.google.com/apps/2006'>
|
|
|
|
<entry>
|
|
|
|
<apps:property name='from' value='(foo@example.com|test@example.com)'/>
|
|
|
|
<apps:property name='label' value='Some label'/>
|
|
|
|
<apps:property name='shouldArchive' value='true'/>
|
|
|
|
</entry>
|
|
|
|
<entry>
|
|
|
|
<apps:property name='hasTheWord' value='from:bar@example.com'/>
|
|
|
|
<apps:property name='shouldStar' value='true'/>
|
|
|
|
<apps:property name='shouldAlwaysMarkAsImportant' value='true'/>
|
|
|
|
</entry>
|
2018-01-04 23:22:23 +00:00
|
|
|
</feed>
|
|
|
|
EOF;
|
2017-12-30 10:28:19 +00:00
|
|
|
|
2018-01-15 09:24:38 +00:00
|
|
|
$this->assertEquals($expected, $result->getXml());
|
2017-11-04 00:32:39 +00:00
|
|
|
}
|
|
|
|
}
|