Ejemplo n.º 1
0
 public function testCanAddModuleAsShim()
 {
     $amdConfig = new \Elgg\Amd\Config();
     $amdConfig->addModule('jquery.form', array('exports' => 'jquery.fn.ajaxform'));
     $configArray = $amdConfig->getConfig();
     $this->assertArrayHasKey('jquery.form', $configArray['shim']);
     $this->assertEquals(array('exports' => 'jquery.fn.ajaxform'), $configArray['shim']['jquery.form']);
 }
Ejemplo n.º 2
0
 public function testCanAddModuleAsShim()
 {
     $amdConfig = new \Elgg\Amd\Config();
     $amdConfig->addModule('jquery.form', array('url' => 'http://foobar.com', 'exports' => 'jquery.fn.ajaxform', 'deps' => array('jquery')));
     $configArray = $amdConfig->getConfig();
     $this->assertArrayHasKey('jquery.form', $configArray['shim']);
     $this->assertEquals(array('exports' => 'jquery.fn.ajaxform', 'deps' => array('jquery')), $configArray['shim']['jquery.form']);
     $this->assertArrayHasKey('jquery.form', $configArray['paths']);
     $this->assertEquals(array('http://foobar.com'), $configArray['paths']['jquery.form']);
     $this->assertTrue($amdConfig->hasModule('jquery.form'));
     $this->assertTrue($amdConfig->hasShim('jquery.form'));
     $amdConfig->removeModule('jquery.form');
     $this->assertFalse($amdConfig->hasModule('jquery.form'));
     $this->assertFalse($amdConfig->hasShim('jquery.form'));
 }
Ejemplo n.º 3
0
 public function testGetConfigTriggersTheConfigAmdPluginHook()
 {
     $hooks = new \Elgg\PluginHooksService();
     $amdConfig = new \Elgg\Amd\Config($hooks);
     $test_input = ['test' => 'test_' . time()];
     $hooks->registerHandler('config', 'amd', function () use($test_input) {
         return $test_input;
     });
     $config = $amdConfig->getConfig();
     $this->assertEquals($test_input, $config);
 }