const TESTING_TYPE = 'report';
const OTHER_TESTING_TYPE = 'module';
+ /**
+ * @var string
+ */
+ protected $basedir;
+
+ /**
+ * @var CRM_Extension_Container_Basic
+ */
+ protected $container;
+
+ /**
+ * @var CRM_Extension_Mapper
+ */
+ protected $mapper;
+
public function setUp(): void {
parent::setUp();
- list ($this->basedir, $this->container) = $this->_createContainer();
+ list($this->basedir, $this->container) = $this->createContainer();
$this->mapper = new CRM_Extension_Mapper($this->container);
}
]);
$this->assertEquals('unknown', $manager->getStatus('test.newextension'));
- $this->download = $this->_createDownload('test.newextension', 'newextension');
+ $download = $this->createDownload('test.newextension', 'newextension');
$testingTypeManager
// no data to replace
// no data to replace
->expects($this->never())
->method('onPostReplace');
- $manager->replace($this->download);
+ $manager->replace($download);
$this->assertEquals('uninstalled', $manager->getStatus('test.newextension'));
$this->assertTrue(file_exists("{$this->basedir}/test.newextension/info.xml"));
$this->assertTrue(file_exists("{$this->basedir}/test.newextension/newextension.php"));
$this->assertEquals('uninstalled', $manager->getStatus('test.whiz.bang'));
$this->assertEquals('oddball', $this->mapper->keyToInfo('test.whiz.bang')->file);
- $this->download = $this->_createDownload('test.whiz.bang', 'newextension');
+ $download = $this->createDownload('test.whiz.bang', 'newextension');
$testingTypeManager
// no data to replace
// no data to replace
->expects($this->never())
->method('onPostReplace');
- $manager->replace($this->download);
+ $manager->replace($download);
$this->assertEquals('uninstalled', $manager->getStatus('test.whiz.bang'));
$this->assertTrue(file_exists("{$this->basedir}/weird/whizbang/info.xml"));
$this->assertTrue(file_exists("{$this->basedir}/weird/whizbang/newextension.php"));
$this->assertEquals('oddball', $this->mapper->keyToInfo('test.whiz.bang')->file);
$this->assertDBQuery('oddball', 'SELECT file FROM civicrm_extension WHERE full_name ="test.whiz.bang"');
- $this->download = $this->_createDownload('test.whiz.bang', 'newextension');
+ $download = $this->createDownload('test.whiz.bang', 'newextension');
$testingTypeManager
->expects($this->once())
$testingTypeManager
->expects($this->once())
->method('onPostReplace');
- $manager->replace($this->download);
+ $manager->replace($download);
$this->assertEquals('installed', $manager->getStatus('test.whiz.bang'));
$this->assertTrue(file_exists("{$this->basedir}/weird/whizbang/info.xml"));
$this->assertTrue(file_exists("{$this->basedir}/weird/whizbang/newextension.php"));
$this->assertEquals('installed-missing', $manager->getStatus('test.whiz.bang'));
// download and reinstall
- $this->download = $this->_createDownload('test.whiz.bang', 'newextension');
+ $download = $this->createDownload('test.whiz.bang', 'newextension');
$testingTypeManager
->expects($this->once())
$testingTypeManager
->expects($this->once())
->method('onPostReplace');
- $manager->replace($this->download);
+ $manager->replace($download);
$this->assertEquals('installed', $manager->getStatus('test.whiz.bang'));
$this->assertTrue(file_exists("{$this->basedir}/test.whiz.bang/info.xml"));
$this->assertTrue(file_exists("{$this->basedir}/test.whiz.bang/newextension.php"));
* @return CRM_Extension_Manager
*/
public function _createManager($typeManagers) {
- //list ($basedir, $c) = $this->_createContainer();
- $mapper = new CRM_Extension_Mapper($this->container);
return new CRM_Extension_Manager($this->container, $this->container, $this->mapper, $typeManagers);
}
/**
- * @param CRM_Utils_Cache_Interface $cache
- * @param null $cacheKey
- *
* @return array
*/
- public function _createContainer(CRM_Utils_Cache_Interface $cache = NULL, $cacheKey = NULL) {
+ private function createContainer() {
$basedir = $this->createTempDir('ext-');
mkdir("$basedir/weird");
mkdir("$basedir/weird/foobar");
mkdir("$basedir/weird/downstream");
file_put_contents("$basedir/weird/downstream/info.xml", "<extension key='test.foo.downstream' type='" . self::TESTING_TYPE . "'><file>oddball</file><requires><ext>test.foo.bar</ext></requires></extension>");
// not needed for now // file_put_contents("$basedir/weird/downstream/oddball.php", "<?php\n");
- $c = new CRM_Extension_Container_Basic($basedir, 'http://example/basedir', $cache, $cacheKey);
+ $c = new CRM_Extension_Container_Basic($basedir, 'http://example/basedir', NULL, NULL);
return [$basedir, $c];
}
/**
- * @param $key
- * @param $file
+ * @param string $key
+ * @param string $file
*
* @return string
*/
- public function _createDownload($key, $file) {
+ private function createDownload($key, $file) {
$basedir = $this->createTempDir('ext-dl-');
file_put_contents("$basedir/info.xml", "<extension key='$key' type='" . self::TESTING_TYPE . "'><file>$file</file></extension>");
file_put_contents("$basedir/$file.php", "<?php\n");