public function testItCanCreateUniqueServiceInstancesWhenSingletonIsDefault()
 {
     $config = ['di' => ['services' => ['example_class' => ['class' => ExampleClass::class, 'singleton' => false]]]];
     Configurator::apply()->configFromArray($config)->withSetting(Configurator::SETTING_DEFAULT_SINGLETON_SERVICES, true)->to($this->container);
     $instance1 = $this->container->get('example_class');
     $instance2 = $this->container->get('example_class');
     assertNotSame($instance1, $instance2);
 }
示例#2
0
 /**
  * @test
  */
 public function shouldBeClonable()
 {
     $map = $this->dayNames;
     $freezedMap = clone $this->dayNames;
     assertTrue($freezedMap !== $map);
     assertSame($map->asPairs()->toArray(), $freezedMap->asPairs()->toArray());
     $freezedMapPairsArrayView = $freezedMap->asPairs()->toArray();
     // Add element to $map (internal state modification).
     $this->storage[$this->dayDates['day after tomorrow']] = 'day after tomorrow';
     // Cloned map will be the same.
     assertNotSame($map->asPairs()->toArray(), $freezedMap->asPairs()->toArray());
     assertSame($freezedMapPairsArrayView, $freezedMap->asPairs()->toArray());
 }
 /**
  * Cloning in case of immutable collection “freeze” elements (useful for result of many lazy operations).
  *
  * @test
  */
 public function shouldBeClonable()
 {
     $collection = new IteratorCollection($array = new \ArrayIterator(array(1, 2, 3, 3)));
     $freezedCollection = clone $collection;
     assertTrue($freezedCollection !== $collection);
     assertSame($collection->toArray(), $freezedCollection->toArray());
     $freezedCollectionArrayView = $freezedCollection->toArray();
     // Add element to $collection (internal state modification).
     $array[4] = 5;
     // Cloned collection will be the same.
     assertNotSame($collection->toArray(), $freezedCollection->toArray());
     assertSame($freezedCollectionArrayView, $freezedCollection->toArray());
 }
 public function isnt($exp1, $exp2, $message = '')
 {
     assertNotSame($exp2, $exp1);
 }