lithium\tests\cases\util\SetTest::testMatchesBasic PHP Method

testMatchesBasic() public method

public testMatchesBasic ( )
    public function testMatchesBasic()
    {
        $a = array(array('Article' => array('id' => 1, 'title' => 'Article 1')), array('Article' => array('id' => 2, 'title' => 'Article 2')), array('Article' => array('id' => 3, 'title' => 'Article 3')));
        $this->assertTrue(Set::matches($a[1]['Article'], array('id=2')));
        $this->assertFalse(Set::matches($a[1]['Article'], array('id>2')));
        $this->assertTrue(Set::matches($a[1]['Article'], array('id>=2')));
        $this->assertFalse(Set::matches($a[1]['Article'], array('id>=3')));
        $this->assertTrue(Set::matches($a[1]['Article'], array('id<=2')));
        $this->assertFalse(Set::matches($a[1]['Article'], array('id<2')));
        $this->assertTrue(Set::matches($a[1]['Article'], array('id>1')));
        $this->assertTrue(Set::matches($a[1]['Article'], array('id>1', 'id<3', 'id!=0')));
        $this->assertTrue(Set::matches(array(), array('3'), 3));
        $this->assertTrue(Set::matches(array(), array('5'), 5));
        $this->assertTrue(Set::matches($a[1]['Article'], array('id')));
        $this->assertTrue(Set::matches($a[1]['Article'], array('id', 'title')));
        $this->assertFalse(Set::matches($a[1]['Article'], array('non-existant')));
        $this->assertTrue(Set::matches($a, '/Article[id=2]'));
        $this->assertFalse(Set::matches($a, '/Article[id=4]'));
        $this->assertTrue(Set::matches($a, array()));
    }