public function testCountable() { $this->assertTrue(is_a(ObjectBag::class, \Countable::class, true)); $bag = new ObjectBag(); $this->assertEquals(0, $bag->count()); $bag = new ObjectBag(['foo' => new \stdClass(), 'bar' => new \stdClass()]); $this->assertEquals(2, $bag->count()); $object1 = new CompleteObject(new SimpleObject('foo', new \stdClass())); $object2 = new CompleteObject(new SimpleObject('bar', new \stdClass())); $bag = (new ObjectBag())->with($object1)->with($object2); $this->assertEquals(2, $bag->count()); $object3 = new CompleteObject(new SimpleObject('foz', new \stdClass())); $object4 = new CompleteObject(new SimpleObject('baz', new \stdClass())); $anotherBag = (new ObjectBag())->with($object3)->with($object4); $bag = $bag->mergeWith($anotherBag); $this->assertEquals(4, $bag->count()); }