Пример #1
0
 public function testToArray()
 {
     $object_data = $this->getRandomScalarValues();
     $object_data['@type'] = 'Trellis\\Tests\\Common\\Fixtures\\TestObject';
     $test_object = new TestObject($object_data);
     $this->assertEquals($object_data, $test_object->toArray());
 }
Пример #2
0
 public function testKeyUnset()
 {
     $items = TestObject::createRandomInstances();
     $list = new UniqueKeyTestObjectList($items);
     $count_before = $list->getSize();
     unset($list[0]);
     $this->assertEquals($count_before - 1, $list->getSize());
 }
Пример #3
0
 protected function createRandomItems()
 {
     $items = [];
     $faker = Faker\Factory::create();
     foreach (TestObject::createRandomInstances() as $item) {
         $items[$faker->word(12)] = $item;
     }
     return $items;
 }
Пример #4
0
 public function testAddItem()
 {
     $items = TestObject::createRandomInstances();
     $list = new TestObjectList();
     foreach ($items as $item) {
         $list->addItem($item);
     }
     // assert item count
     $expected_item_count = count($items);
     $this->assertEquals($expected_item_count, count($list));
     // assert item order
     foreach ($list as $index => $object) {
         $expected_item = $items[$index];
         $this->assertEquals($expected_item, $object);
     }
 }
Пример #5
0
 /**
  * @expectedException Trellis\Common\Error\RuntimeException
  */
 public function testUniqueness()
 {
     $items = TestObject::createRandomInstances();
     $list = new UniqueTestObjectList($items);
     $list->addItem($items[0]);
 }
Пример #6
0
 protected function createRandomItems()
 {
     return TestObject::createRandomInstances();
 }