mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
357ed7ad7e
There are also a few general corrections to PHPDocs that I noticed along the way (e.g. adding `|null` when the method is returning a null value. There are some cases where either the return type or the whole PHPDoc was duplicated from the parent class - in those cases I've simply removed the duplication.
43 lines
1.3 KiB
PHP
43 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace SilverStripe\Dev\Tests;
|
|
|
|
use SilverStripe\Dev\Constraint\SSListContainsOnly;
|
|
use SilverStripe\Dev\Constraint\SSListContainsOnlyMatchingItems;
|
|
use SilverStripe\Dev\SapphireTest;
|
|
use SilverStripe\ORM\ArrayList;
|
|
use SilverStripe\Security\Member;
|
|
|
|
class SSListContainsOnlyMatchingItemsTest extends SapphireTest
|
|
{
|
|
public function testEvaluateListMatchesCorrectly()
|
|
{
|
|
$constraint = new SSListContainsOnlyMatchingItems(['IsActive' => 1]);
|
|
|
|
$this->assertTrue($constraint->evaluate($this->getListToMatch(), '', true));
|
|
}
|
|
|
|
/**
|
|
* @return ArrayList<Member>
|
|
*/
|
|
private function getListToMatch()
|
|
{
|
|
$list = ArrayList::create();
|
|
$list->push(Member::create(['FirstName' => 'Ingo', 'Surname' => 'Schommer', 'IsActive' => 1]));
|
|
$list->push(Member::create(['FirstName' => 'Sam', 'Surname' => 'Minnee', 'IsActive' => 1]));
|
|
|
|
return $list;
|
|
}
|
|
|
|
|
|
public function testEvaluateListDoesNotMatchWrongMatches()
|
|
{
|
|
$constraint = new SSListContainsOnlyMatchingItems(['IsActive' => 1]);
|
|
|
|
$failingList = $this->getListToMatch();
|
|
$failingList->push(Member::create(['FirstName' => 'Foo', 'IsActive' => 0]));
|
|
|
|
$this->assertFalse($constraint->evaluate($failingList, '', true));
|
|
}
|
|
}
|