Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jackrabbithanna/c052115747553702cbf88ba08694f4a8 to your computer and use it in GitHub Desktop.
Save jackrabbithanna/c052115747553702cbf88ba08694f4a8 to your computer and use it in GitHub Desktop.
<?php
use Drupal\Tests\civicrm_tests\FunctionalJavascript\CivicrmFunctionalJavascriptBase;
/**
* Class CivicrmExtensionTests
*
* @group CivicrmTests
*/
class CivicrmExtensionTests extends CivicrmFunctionalJavascriptBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
$additional_modules = ['dblog'];
$this->addInstallModules($additional_modules);
parent::setUp();
$development_settings = [
'userFrameworkLogging' => 1,
'debug_enabled' => 1,
'backtrace' => '1',
'environment' => 'Development',
];
$this->setCivicrmSettings($development_settings);
}
/**
* Test installing CiviCRM extensions
*
* @throws \CRM_Extension_Exception
* @throws \CiviCRM_API3_Exception
* @throws \Drupal\Core\Entity\EntityStorageException
*/
public function testCivicrmInstallCiviDiscountExtension() {
$this->installShoreditchExtension();
// install CiviDiscount
$this->installCivicrmExtensions('org.civicrm.module.cividiscount');
$user_permissions = array_merge($this->civicrm_admin_permissions, [
'administer CiviDiscount',
]);
$admin_user = $this->drupalCreateUser($user_permissions);
$this->drupalLogin($admin_user);
//$this->drupalGet('civicrm/admin/extensions', ['query' => ['reset' => 1]]);
$this->drupalGet('civicrm/cividiscount');
$assertSession = $this->assertSession();
$session = $this->getSession();
$page = $session->getPage();
$page->findButton("New Discount Code");
}
/**
* Tests CiviCRM installation and successful installation of Mosaico
*
* @throws \CRM_Extension_Exception
* @throws \CiviCRM_API3_Exception
* @throws \Drupal\Core\Entity\EntityStorageException
*/
public function testCivicrmInstallMosiacoExtension() {
$this->installShoreditchExtension();
$this->installCivicrmExtensions([
'org.civicrm.flexmailer',
'uk.co.vedaconsulting.mosaico',
]);
$user_permissions = array_merge($this->drupal_admin_permissions, $this->civicrm_admin_permissions, [
'access toolbar',
'edit message templates',
'access CiviMail',
'access contact reference fields',
]);
$admin_user = $this->drupalCreateUser($user_permissions);
$this->drupalLogin($admin_user);
$url_options = ['fragment' => '/mailing/new'];
$this->drupalGet('civicrm/a', $url_options);
$session = $this->getSession();
$page = $session->getPage();
$result = $page->waitFor(5000 / 1000, function () use ($page) {
return $page->find('css', '.crm-mosaico-page .crm_wizard');
});
$expected_message = 'Mosaico editor new mailing page ' . (!empty($result) ? 'loaded correctly.' : 'did not load correctly.');
$this->assertNotEmpty($result, $expected_message);
$page->find('css', '#s2id_inputFrom');
}
/**
* Test CiviCRM installation and successful installation of Contact Layout Editor extension
*
* @throws \CRM_Extension_Exception
* @throws \CiviCRM_API3_Exception
* @throws \Drupal\Core\Entity\EntityStorageException
*/
public function testCivicrmInstallContactLayoutExtension() {
$this->installShoreditchExtension();
// to install contact layout editor
$this->installCivicrmExtensions([
// 'org.civicrm.api4', // uncommet for Civi versions before 5.19
'org.civicrm.angularprofiles',
'org.civicrm.contactlayout',
]);
$user_permissions = array_merge($this->drupal_admin_permissions, $this->civicrm_admin_permissions, [
'access toolbar',
]);
$admin_user = $this->drupalCreateUser($user_permissions);
$this->drupalLogin($admin_user);
$url_options = ['fragment' => '/contact-summary-editor'];
$this->drupalGet("civicrm/a", $url_options);
$session = $this->getSession();
$page = $session->getPage();
$result = $page->waitFor(5000 / 1000, function () use ($page) {
return $page->find('css', '#contactLayoutEditor');
});
$expected_message = 'Contact Summary layout editor page ' . (!empty($result) ? 'loaded correctly.' : 'did not load correctly.');
$this->assertNotEmpty($result, $expected_message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment