/** * remove will return removed element if the requested key is set */ public function testRemoveWillReturnRemovedElementIfTheRequestedKeyIsSet() { $element1 = new \stdClass(); $element1->Name = 'EL 1'; $element2 = new \stdClass(); $element2->Name = 'EL 2'; $Collection = new \MySQLExtractor\Common\Collection(); $Collection->set('index2', $element2); $Collection->set('index1', $element1); $this->assertSame($element2, $Collection->remove('index2')); }
/** * count will return the number of elements that have been added */ public function testCountWillReturnTheNumberOfElementsThatHaveBeenAdded() { $element1 = new \stdClass(); $element1->Name = 'EL 1'; $element2 = new \stdClass(); $element2->Name = 'EL 2'; $Collection = new \MySQLExtractor\Common\Collection(); $Collection->set('index2', $element2); $Collection->set('index1', $element1); $this->assertEquals(2, $Collection->count()); }
/** * removeElement will return true if the element is in array */ public function testRemoveElementWillReturnTrueIfTheElementIsInArray() { $element1 = new \stdClass(); $element1->Name = 'EL 1'; $element2 = new \stdClass(); $element2->Name = 'EL 2'; $Collection = new \MySQLExtractor\Common\Collection(); $Collection->set('index2', $element2); $Collection->set('index1', $element1); $this->assertTrue($Collection->removeElement($element2)); }
/** * containsKey will return false if an element is not set for the input key */ public function testContainsKeyWillReturnFalseIfAnElementIsNotSetForTheInputKey() { $element1 = new \stdClass(); $element1->Name = 'EL 1'; $element2 = new \stdClass(); $element2->Name = 'EL 2'; $Collection = new \MySQLExtractor\Common\Collection(); $Collection->set('index2', $element2); $Collection->set('index1', $element1); $this->assertFalse($Collection->containsKey('index3')); }
/** * indexOf will return the key name for the element */ public function testIndexOfWillReturnTheKeyNameForTheElement() { $element1 = new \stdClass(); $element1->Name = 'EL 1'; $element2 = new \stdClass(); $element2->Name = 'EL 2'; $Collection = new \MySQLExtractor\Common\Collection(); $Collection->set('index2', $element2); $Collection->set('index1', $element1); $this->assertEquals('index1', $Collection->indexOf($element1)); $this->assertEquals('index2', $Collection->indexOf($element2)); }