From 62412f00d9d6ca0af5fa39b6aa53848adcfccb88 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 4 Jul 2023 07:38:44 +1200 Subject: [PATCH] Remove now unsed createEvent test function --- tests/phpunit/CRM/Upgrade/SnapshotTest.php | 28 +++++++++++---- .../Token/ImpliedContextSubscriberTest.php | 5 +++ tests/phpunit/CiviTest/CiviUnitTestCase.php | 35 ------------------- 3 files changed, 26 insertions(+), 42 deletions(-) diff --git a/tests/phpunit/CRM/Upgrade/SnapshotTest.php b/tests/phpunit/CRM/Upgrade/SnapshotTest.php index a6a8ae366200..a5324a7fcc88 100644 --- a/tests/phpunit/CRM/Upgrade/SnapshotTest.php +++ b/tests/phpunit/CRM/Upgrade/SnapshotTest.php @@ -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'); @@ -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) { @@ -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++) { @@ -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') @@ -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); @@ -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); } diff --git a/tests/phpunit/Civi/Token/ImpliedContextSubscriberTest.php b/tests/phpunit/Civi/Token/ImpliedContextSubscriberTest.php index 134260b032ec..88ea3c4bf1f5 100644 --- a/tests/phpunit/Civi/Token/ImpliedContextSubscriberTest.php +++ b/tests/phpunit/Civi/Token/ImpliedContextSubscriberTest.php @@ -3,6 +3,11 @@ class ImpliedContextSubscriberTest extends \CiviUnitTestCase { + public function tearDown(): void { + $this->quickCleanUpFinancialEntities(); + parent::tearDown(); + } + public function testParticipantImplicitEvent(): void { $participantId = $this->participantCreate(); diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index 1d692efdd74a..0690e21edf92 100644 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -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; @@ -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. *