gmail-filter-builder/tests/GmailFilterTest.php

45 lines
1.1 KiB
PHP
Raw Normal View History

2016-10-12 21:27:30 +00:00
<?php
class GmailFilterTest extends \PHPUnit_Framework_TestCase
{
2016-10-12 21:47:33 +00:00
/**
* @var GmailFilter
*/
private $filter;
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->filter = new GmailFilter();
}
public function testSingleFrom() {
2016-10-12 21:27:30 +00:00
// TODO: Does this need to be done each time?
2016-10-12 21:47:33 +00:00
$output = $this->createBuilder([
$this->filter->from(['foo@example.com'])
]);
2016-10-12 21:27:30 +00:00
2016-10-12 21:47:33 +00:00
$this->assertContains('<apps:property name=\'from\' value=\'foo@example.com\'/>', $output);
2016-10-12 21:27:30 +00:00
}
public function testMultipleFrom() {
2016-10-12 21:47:33 +00:00
$output = $this->createBuilder([
$this->filter->from(['foo@example.com', 'bar@example.com'])
]);
2016-10-12 21:27:30 +00:00
2016-10-12 21:47:33 +00:00
$this->assertContains('<apps:property name=\'from\' value=\'foo@example.com OR bar@example.com\'/>', $output);
}
2016-10-12 21:27:30 +00:00
2016-10-12 21:47:33 +00:00
/**
* @param GmailFilter[] $filters An array of filters.
*
* @return string A string representation of GmailFilterBuilder.
*/
private function createBuilder($filters) {
return (string) new GmailFilterBuilder($filters);
2016-10-12 21:27:30 +00:00
}
}