mirror of
https://github.com/opdavies/gmail-filter-builder.git
synced 2025-01-22 20:17:31 +00:00
Same conditions are kept within a filter group
This commit is contained in:
parent
1578cc81a3
commit
f700382355
|
@ -30,8 +30,13 @@ class FilterGroup
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function toArray(): array
|
||||
/**
|
||||
* Get all filters within this filter group.
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function all(): Collection
|
||||
{
|
||||
return $this->filters->toArray();
|
||||
return $this->filters;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,24 @@ class OtherwiseTest extends TestCase
|
|||
->trash()
|
||||
);
|
||||
|
||||
$this->assertCount(3, $filters->toArray());
|
||||
$this->assertCount(3, $filters->all());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function same_conditions_are_kept_between_filters()
|
||||
{
|
||||
$filters = FilterGroup::if(
|
||||
Filter::create()
|
||||
->has('to:me@example.com subject:Foo')
|
||||
->read()
|
||||
)->otherwise(
|
||||
Filter::create()
|
||||
->has('to:me@example.com subject:Bar')
|
||||
->trash()
|
||||
);
|
||||
|
||||
$filters->all()->each(function (Filter $filter) {
|
||||
$this->assertTrue($filter->getConditions()->contains('to:me@example.com'));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue