Ejemplo n.º 1
0
    public function test_it_should_use_reference2()
    {
        $bemjson = ['block' => 'button', 'content' => ['block' => 'nested', 'content' => ['elem' => 'elem', 'mods' => ['red']]]];
        $matcher = new \BEM\Matcher('button', function (\BEM\Context $ctx) {
            $ctx->mod('green', true);
        });
        $id = $this->bh->addMatcher($matcher->expression, $matcher);
        $testWithGreen = '
<div class="button button--green">
  
  <div class="nested">
    
    <div class="nested__elem nested__elem--red">
      
    </div>

  </div>

</div>
';
        $out = $this->bh->apply($bemjson);
        static::assertSame($testWithGreen, $out);
        // change closure
        $matcher->matcher = function (\BEM\Context $ctx) {
            $ctx->mod('blue', true);
        };
        $testWithBlue = '
<div class="button button--blue">
  
  <div class="nested">
    
    <div class="nested__elem nested__elem--red">
      
    </div>

  </div>

</div>
';
        $out = $this->bh->apply($bemjson);
        static::assertSame($testWithBlue, $out);
    }