/**
  * @test
  */
 public function itShouldReturnFalseIfTheExpressionDoesNotReturnBoolean()
 {
     $condition = new ExpressionCondition('user["tags"]', $this->language);
     $context = new Context();
     $context->set('user', ['active' => true, 'tags' => array('symfony2', 'hellofresh')]);
     $this->assertFalse($condition->holdsFor($context));
 }
 /**
  * @test
  * @dataProvider valueAvailable
  */
 public function itReturnsWhetherItOperatorHoldsForTheValueIfAvailable($value, $expected)
 {
     $condition = new OperatorCondition('age', new GreaterThan(42));
     $context = new Context();
     $context->set('age', $value);
     $this->assertEquals($expected, $condition->holdsFor($context));
 }
    public function testLoadFromYaml()
    {
        $yaml = <<<YML
features:
  - name: some-feature
    conditions:
     - name: operator-condition
       key: user_id
       operator:
           name: greater-than
           value: 41
       status: conditionally-active
  - name: some-feature2
    conditions:
     - name: operator-condition
       key: user_id
       operator:
           name: greater-than
           value: 42
       status: conditionally-active
YML;
        $serializer = new Serializer();
        $features = $serializer->deserialize(Yaml::parse($yaml)['features']);
        $manager = new FeatureManager($features);
        $context = new Context();
        $context->set('user_id', 42);
        $this->assertTrue($manager->isActive('some-feature', $context));
    }
 public function testLoadFromYaml()
 {
     $language = new ExpressionLanguage();
     $expression = new ExpressionCondition('user["active"] and product["price"] / 100 >= 0.2', $language);
     $manager = new FeatureManager();
     $manager->addFeature(new Feature('feature1', new ArrayList([$expression])));
     $context = new Context();
     $context->set('user', ['active' => true]);
     $context->set('product', ['price' => 30]);
     $this->assertTrue($manager->isActive('feature1', $context));
 }
 /**
  * @test
  */
 public function itDoesNotHaveAValueThatWasNeverSet()
 {
     $context = new Context();
     $this->assertFalse($context->containsKey('foo'));
 }