Example #1
0
 public function testKeyNormalization()
 {
     $collection = new Collection(['X' => 'a', 'y' => 'b', 'Z' => 'C']);
     $collection->addNormalizer(function (&$value, &$key) {
         $key = strtoupper($key);
         $value = strtolower($value);
     });
     // @todo allow key normalization for previously stored entries too!
     $collection['d'] = 'TEST';
     $this->assertEquals(['X' => 'a', 'Y' => 'b', 'Z' => 'c', 'D' => 'test'], $collection->getInternalValue());
 }
 public function testNormalizersClearing()
 {
     $collection = new Collection(['X' => 'a', 'y' => 'b', 'Z' => 'C']);
     $collection->addNormalizer(function (&$value) {
         $value = strtolower($value);
     });
     $this->assertCount(1, $collection->getNormalizers());
     $collection->clearNormalizers();
     $this->assertEmpty($collection->getNormalizers());
 }