/**
  * adding an element will return true
  */
 public function testAddingAnElementWillReturnTrue()
 {
     $element1 = new \stdClass();
     $element1->Name = 'EL 2';
     $Collection = new \MySQLExtractor\Common\Collection();
     $response = $Collection->add($element1);
     $this->assertTrue($response);
     $elements = \PHPUnit_Framework_Assert::readAttribute($Collection, 'elements');
     $this->assertEquals(array($element1), $elements);
 }
 /**
  * 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'));
 }
 /**
  * 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));
 }
 /**
  * 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());
 }
 /**
  * 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));
 }
 /**
  * toArray will return an empty array if no elements are set
  */
 public function testToArrayWillReturnAnEmptyArrayIfNoElementsAreSet()
 {
     $Collection = new \MySQLExtractor\Common\Collection();
     $this->assertEquals(array(), $Collection->toArray());
 }