public function setUp()
 {
     $toggleCollection = new InMemoryCollection();
     $toggleCollection->set('foo', $this->createToggle('foo', true));
     $toggleCollection->set('bar', $this->createToggle('foo', false));
     $this->contextFactory = new StubContextFactory();
     $this->toggleManager = new ToggleManager($toggleCollection);
 }
 /**
  * @param InMemoryCollection $toggleCollection
  * @return array
  */
 public function serialize(InMemoryCollection $toggleCollection)
 {
     $serializer = new ToggleSerializer(new OperatorConditionSerializer(new OperatorSerializer()));
     $ret = array();
     foreach ($toggleCollection->all() as $key => $toggle) {
         $ret[$key] = $serializer->serialize($toggle);
     }
     return $ret;
 }
 /**
  * @test
  */
 public function it_serializes_and_deserializes_a_collection()
 {
     $collection = new InMemoryCollection();
     $operator = new LessThan(42);
     $condition = new OperatorCondition('user_id', $operator);
     $toggle = new Toggle('toggling', array($condition));
     $collection->set('some-feature', $toggle);
     $serializer = new InMemoryCollectionSerializer();
     $serialized = $serializer->serialize($collection);
     $collection2 = $serializer->deserialize($serialized);
     $this->assertEquals($collection, $collection2);
 }