Exemplo n.º 1
0
 public function testRemove()
 {
     $aTest = ['one', 'two', 'three'];
     // sad
     $this->assertEquals(false, ArrayHelper::remove($aTest, 'twelve'));
     // happy
     $this->assertEquals(true, ArrayHelper::remove($aTest, 'two'));
     $this->assertEquals(false, ArrayHelper::contains($aTest, 'two'));
 }
Exemplo n.º 2
0
 /**
  * @param array $entities
  * @return array
  */
 public function meetCriteria(array $entities)
 {
     $aNotCriteriaItems = $this->_Criteria->meetCriteria($entities);
     $aNotEntities = $entities;
     foreach ($aNotCriteriaItems as $Item) {
         ArrayHelper::remove($aNotEntities, $Item);
     }
     return $aNotEntities;
 }
Exemplo n.º 3
0
 public function testNotCriteria()
 {
     $aTest = [['name' => 'one', 'type' => 1], ['name' => 'two', 'type' => 2], ['name' => 'Fred', 'type' => 1]];
     $MatchesOne = new KeyValue('type', '1');
     $MatchesFred = new KeyValue('name', 'Fred');
     $aResult = $MatchesOne->_and($MatchesFred->_not())->meetCriteria($aTest);
     $this->assertEquals(1, count($aResult));
     $this->assertTrue(ArrayHelper::contains($aResult, 'one', 'name'));
     $this->assertFalse(ArrayHelper::contains($aResult, 'Fred', 'name'));
 }
Exemplo n.º 4
0
 /**
  * @param array $entities
  * @return array
  */
 public function meetCriteria(array $entities)
 {
     $aFirstCriteriaItems = $this->_Criteria->meetCriteria($entities);
     $aOtherCriteriaItems = $this->_OtherCriteria->meetCriteria($entities);
     foreach ($aOtherCriteriaItems as $Item) {
         if (!ArrayHelper::contains($aFirstCriteriaItems, $Item)) {
             $aFirstCriteriaItems[] = $Item;
         }
     }
     return $aFirstCriteriaItems;
 }