Skip to content

Commit

Permalink
Remove now unsed createEvent test function
Browse files Browse the repository at this point in the history
  • Loading branch information
eileenmcnaughton committed Jul 3, 2023
1 parent 3001e23 commit 62412f0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 42 deletions.
28 changes: 21 additions & 7 deletions tests/phpunit/CRM/Upgrade/SnapshotTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,22 @@ protected function setUp(): void {
CRM_Upgrade_Snapshot::$cleanupAfter = 4;
}

public function testTableNames_good() {
public function tearDown(): void {
$this->quickCleanUpFinancialEntities();
parent::tearDown();
}

/**
* @throws \CRM_Core_Exception
*/
public function testTableNamesGood(): void {
$this->assertEquals('snap_civicrm_v5_45_stuff', CRM_Upgrade_Snapshot::createTableName('civicrm', '5.45', 'stuff'));
$this->assertEquals('snap_civicrm_v5_50_stuffy_things', CRM_Upgrade_Snapshot::createTableName('civicrm', '5.50', 'stuffy_things'));
$this->assertEquals('snap_oauth_client_v12_34_ext_things', CRM_Upgrade_Snapshot::createTableName('oauth_client', '12.34', 'ext_things'));
$this->assertEquals('snap_oauth_client_v0_1234_ext_things', CRM_Upgrade_Snapshot::createTableName('oauth_client', '0.1234', 'ext_things'));
}

public function testTableNames_bad() {
public function testTableNamesBad(): void {
try {
CRM_Upgrade_Snapshot::createTableName('civicrm', '5.45', 'ab&cd');
$this->fail('Accepted invalid name');
Expand All @@ -28,7 +36,7 @@ public function testTableNames_bad() {
$this->assertRegExp('/Malformed snapshot name/', $e->getMessage());
}
try {
CRM_Upgrade_Snapshot::createTableName('civicrm', '5.45', 'loremipsumdolorsitametconsecteturadipiscingelitseddoeiusmod');
CRM_Upgrade_Snapshot::createTableName('civicrm', '5.45', 'long_table_name_that_is_too_long_for_the_validation');
$this->fail('Accepted excessive name');
}
catch (CRM_Core_Exception $e) {
Expand All @@ -38,11 +46,15 @@ public function testTableNames_bad() {

/**
* This example creates a snapshot based on particular sliver of data (ie
* the "display_name" and "sort_name" for "Individual" records). It ensures that:
* the "display_name" and "sort_name" for "Individual" records). It ensures
* that:
*
* 1. Some columns are copied - while other columns are not (based on `select()`).
* 1. Some columns are copied - while other columns are not (based on
* `select()`).
* 2. Some rows are copied - while other rows are not (based on `where()`).
* 3. Multiple pages of data are copied.
*
* @throws \CRM_Core_Exception
*/
public function testContent(): void {
for ($i = 0; $i < 15; $i++) {
Expand Down Expand Up @@ -84,7 +96,7 @@ public function testBasicLifecycle(): void {
$this->organizationCreate([], $i);
}
$this->eventCreateUnpaid([]);
$this->eventCreateUnpaid([]);
$this->eventCreateUnpaid([], 'second');

$this->runAll(CRM_Upgrade_Snapshot::createTasks('civicrm', '5.45', 'names', CRM_Utils_SQL_Select::from('civicrm_contact')
->select('id, display_name, sort_name')
Expand Down Expand Up @@ -117,6 +129,8 @@ public function testBasicLifecycle(): void {
* ex: "table_1.column_1"
* @param string $actualField
* ex: "table_2.column_2"
*
* @throws \Civi\Core\Exception\DBQueryException
*/
protected function assertSameSchema(string $expectField, string $actualField): void {
[$expectTable, $expectColumn] = explode('.', $expectField);
Expand All @@ -138,7 +152,7 @@ protected function assertSameSchema(string $expectField, string $actualField): v
}

protected function runAll(iterable $tasks): void {
$queue = Civi::queue('snaptest', ['type' => 'Memory']);
$queue = Civi::queue('snap-test', ['type' => 'Memory']);
foreach ($tasks as $task) {
$queue->createItem($task);
}
Expand Down
5 changes: 5 additions & 0 deletions tests/phpunit/Civi/Token/ImpliedContextSubscriberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@

class ImpliedContextSubscriberTest extends \CiviUnitTestCase {

public function tearDown(): void {
$this->quickCleanUpFinancialEntities();
parent::tearDown();
}

public function testParticipantImplicitEvent(): void {
$participantId = $this->participantCreate();

Expand Down
35 changes: 0 additions & 35 deletions tests/phpunit/CiviTest/CiviUnitTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
use Civi\Api4\Contribution;
use Civi\Api4\CustomField;
use Civi\Api4\CustomGroup;
use Civi\Api4\Event;
use Civi\Api4\ExampleData;
use Civi\Api4\FinancialAccount;
use Civi\Api4\FinancialType;
Expand Down Expand Up @@ -1007,40 +1006,6 @@ public function contributionDelete(int $contributionID) {
]);
}

/**
* Create an Event.
*
* @param array $params
* Name-value pair for an event.
* @param string|int $identifier
*
* @return array
*
* @throws \CRM_Core_Exception
*
* @noinspection PhpUnhandledExceptionInspection
* @noinspection PhpDocMissingThrowsInspection
*/
public function eventCreate(array $params = [], string $identifier = 'event'): array {
// if no contact was passed, make up a dummy event creator
if (!isset($params['contact_id'])) {
$params['contact_id'] = $this->_contactCreate([
'contact_type' => 'Individual',
'first_name' => 'Event',
'last_name' => 'Creator',
]);
}

$params = array_merge($this->getExampleData('Event', 'PaidEvent'), $params);

if (!empty($params['payment_processor_id'])) {
$params['payment_processor'] = is_array($params['payment_processor_id']) ? $params['payment_processor_id'] : [$params['payment_processor_id']];
}
$event = Event::create(FALSE)->setValues($params)->execute()->first();
$this->ids['Event'][$identifier] = $event['id'];
return $event;
}

/**
* Delete event.
*
Expand Down

0 comments on commit 62412f0

Please sign in to comment.