Ejemplo n.º 1
0
 /**
  * Setup an active module with an entity -- then entirely uninstall the
  * module
  */
 public function testUninstallModule()
 {
     // create first managed entity ('foo')
     $decls = array();
     $decls[] = $this->fixtures['com.example.one-foo'];
     $me = new CRM_Core_ManagedEntities($this->modules, $decls);
     $me->reconcile();
     $foo = $me->get('com.example.one', 'foo');
     $this->assertEquals('CRM_Example_One_Foo', $foo['name']);
     $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_option_value WHERE name = "CRM_Example_One_Foo"');
     // then destroy module; note that decls go away
     unset($this->modules['one']);
     $me = new CRM_Core_ManagedEntities($this->modules, array());
     $me->reconcile();
     $fooNew = $me->get('com.example.one', 'foo');
     $this->assertTrue(NULL === $fooNew);
     $this->assertDBQuery(0, 'SELECT count(*) FROM civicrm_option_value WHERE name = "CRM_Example_One_Foo"');
 }
 /**
  * Setup an active module with an entity -- then entirely uninstall the
  * module
  */
 function testUninstallModule()
 {
     // create first managed entity ('foo')
     $decls = array();
     $decls[] = array('module' => 'com.example.one', 'name' => 'foo', 'entity' => 'CustomSearch', 'params' => array('version' => 3, 'class_name' => 'CRM_Example_One_Foo', 'is_reserved' => 1));
     $me = new CRM_Core_ManagedEntities($this->modules, $decls);
     $me->reconcile();
     $foo = $me->get('com.example.one', 'foo');
     $this->assertEquals('CRM_Example_One_Foo', $foo['name']);
     $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_option_value WHERE name = "CRM_Example_One_Foo"');
     // then destory module; note that decls go away
     unset($this->modules['one']);
     $me = new CRM_Core_ManagedEntities($this->modules, array());
     $me->reconcile();
     $fooNew = $me->get('com.example.one', 'foo');
     $this->assertTrue(NULL === $fooNew);
     $this->assertDBQuery(0, 'SELECT count(*) FROM civicrm_option_value WHERE name = "CRM_Example_One_Foo"');
 }