コード例 #1
0
 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
ファイル: PairMapTest.php プロジェクト: alexeyshockov/colada
 /**
  * @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());
 }
コード例 #3
0
 /**
  * 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());
 }
コード例 #4
0
 public function isnt($exp1, $exp2, $message = '')
 {
     assertNotSame($exp2, $exp1);
 }