/**
  * Check that the parsing of the callbacks is working.
  *
  * @return void
  */
 public function testCallbackParsing()
 {
     $this->aliasContaoClass('Session');
     $this->aliasContaoClass('System');
     $this->aliasContaoClass('Controller');
     $this->aliasContaoClass('Backend');
     $this->aliasContaoClass('DataContainer');
     $dispatcher = new EventDispatcher();
     $container = new DefaultContainer('tl_test');
     $event = new BuildDataDefinitionEvent($container);
     $builder = $this->mockBuilderWithDca(array('fields' => array('testProperty' => array('save_callback' => array(function () {
         return 'executed';
     })))), $event::NAME, $dispatcher);
     $builder->build($event->getContainer(), $event);
     $environment = new DefaultEnvironment();
     $environment->setDataDefinition($container);
     $event = new EncodePropertyValueFromWidgetEvent($environment, new DefaultModel(), new PropertyValueBag());
     $event->setProperty('testProperty');
     $this->assertEquals(1, count($dispatcher->getListeners(EncodePropertyValueFromWidgetEvent::NAME)));
     foreach ($dispatcher->getListeners(EncodePropertyValueFromWidgetEvent::NAME) as $listener) {
         /** @var AbstractCallbackListener $listener */
         $this->assertTrue($listener->wantToExecute($event));
         $event->setValue('testvalue');
         $listener($event);
         $this->assertEquals('executed', $event->getValue());
     }
     $event->setProperty('testProperty2');
     foreach ($dispatcher->getListeners(EncodePropertyValueFromWidgetEvent::NAME) as $listener) {
         /** @var AbstractCallbackListener $listener */
         $this->assertFalse($listener->wantToExecute($event));
     }
 }
 public function mockEnvironment($dataContainerName)
 {
     $environment = new DefaultEnvironment();
     $environment->setDataDefinition(new DefaultContainer($dataContainerName));
     return $environment;
 }