Skip to content

Commit

Permalink
Merge branch '3.x' into appgroup_functional_teamInvitationstest
Browse files Browse the repository at this point in the history
  • Loading branch information
shishir-intelli authored Nov 15, 2023
2 parents 78b7bd0 + 647289b commit 523fad7
Show file tree
Hide file tree
Showing 15 changed files with 80 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

namespace Drupal\Tests\apigee_edge_actions\Kernel;

use Drupal\apigee_edge\Plugin\EdgeKeyTypeInterface;
use Drupal\Core\Database\Database;
use Drupal\dblog\Controller\DbLogController;
use Drupal\Tests\apigee_mock_api_client\Traits\ApigeeMockApiClientHelperTrait;
Expand Down Expand Up @@ -67,6 +68,11 @@ class ApigeeEdgeActionsRulesKernelTestBase extends RulesKernelTestBase {
* {@inheritdoc}
*/
protected function setUp(): void {
// Skipping the test if instance type is Public.
$instance_type = getenv('APIGEE_EDGE_INSTANCE_TYPE');
if (!empty($instance_type) && $instance_type === EdgeKeyTypeInterface::INSTANCE_TYPE_HYBRID) {
$this->markTestSkipped('This test suite is expecting a PUBLIC instance type.');
}
parent::setUp();

$this->storage = $this->container->get('entity_type.manager')->getStorage('rules_reaction_rule');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

namespace Drupal\Tests\apigee_edge_teams\Kernel\Entity;

use Drupal\KernelTests\KernelTestBase;
use Drupal\Tests\apigee_edge\Kernel\ApigeeEdgeKernelTestBase;
use Drupal\Tests\apigee_edge\Kernel\ApigeeEdgeKernelTestTrait;
use Drupal\Tests\apigee_mock_api_client\Traits\ApigeeMockApiClientHelperTrait;

Expand All @@ -32,7 +32,7 @@
* @group apigee_edge_teams
* @group apigee_edge_teams_kernel
*/
class TeamViewBuilderTest extends KernelTestBase {
class TeamViewBuilderTest extends ApigeeEdgeKernelTestBase {

use ApigeeMockApiClientHelperTrait, ApigeeEdgeKernelTestTrait;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
namespace Drupal\Tests\apigee_edge_teams\Kernel;

use Apigee\Edge\Api\Management\Entity\Company;
use Drupal\KernelTests\KernelTestBase;
use Drupal\Tests\apigee_edge\Kernel\ApigeeEdgeKernelTestBase;
use Drupal\Tests\apigee_edge\Traits\EntityControllerCacheUtilsTrait;

/**
Expand All @@ -31,7 +31,7 @@
* @group apigee_edge_teams
* @group apigee_edge_teams_kernel
*/
class EntityControllerCacheTest extends KernelTestBase {
class EntityControllerCacheTest extends ApigeeEdgeKernelTestBase {

use EntityControllerCacheUtilsTrait;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
use Drupal\apigee_edge_teams\Entity\TeamInvitation;
use Drupal\apigee_edge_teams\Entity\TeamInvitationInterface;
use Drupal\apigee_edge_teams\Entity\TeamRoleInterface;
use Drupal\KernelTests\KernelTestBase;
use Drupal\Tests\apigee_edge\Kernel\ApigeeEdgeKernelTestBase;
use Drupal\Tests\apigee_mock_api_client\Traits\ApigeeMockApiClientHelperTrait;

/**
Expand All @@ -35,7 +35,7 @@
* @group apigee_edge_teams
* @group apigee_edge_teams_kernel
*/
class TeamInvitationEventsTest extends KernelTestBase {
class TeamInvitationEventsTest extends ApigeeEdgeKernelTestBase {

use ApigeeMockApiClientHelperTrait {
apigeeTestHelperSetup as baseSetUp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ protected function syslogWrapper($level, $entry) {
$log_path = \Drupal::service('file_system')->realpath('public://');
}
// Add test prefix to the log file.
// @phpstan-ignore-next-line
$log_path .= '/apigee_edge_debug-' . str_replace('test', '', $this->database->tablePrefix()) . '.log';
$log_path .= '/apigee_edge_debug-' . str_replace('test', '', $this->database->getPrefix()) . '.log';
// Do not fail a test just because the fail is not writable.
@error_log($entry . PHP_EOL, 3, $log_path);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ protected function syslogWrapper($level, $entry) {
$log_path = \Drupal::service('file_system')->realpath('public://');
}
// Add test id as a suffix to the log file.
// @todo tablePrefix() is deprecated in Drupal 10.1
// @phpstan-ignore-next-line
$log_path .= '/syslog-' . str_replace('test', '', $this->database->tablePrefix()) . '.log';
$log_path .= '/syslog-' . str_replace('test', '', $this->database->getPrefix()) . '.log';
// Do not fail a test just because the fail is not writable.
@error_log($entry . PHP_EOL, 3, $log_path);
}
Expand Down
6 changes: 6 additions & 0 deletions tests/src/Functional/ApigeeEdgeFunctionalTestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

namespace Drupal\Tests\apigee_edge\Functional;

use Drupal\apigee_edge\Plugin\EdgeKeyTypeInterface;
use Drupal\Tests\apigee_edge\Traits\ApigeeEdgeFunctionalTestTrait;
use Drupal\Tests\BrowserTestBase;

Expand All @@ -40,6 +41,11 @@ abstract class ApigeeEdgeFunctionalTestBase extends BrowserTestBase {
* {@inheritdoc}
*/
protected function setUp(): void {
// Skipping the test if instance type is Public.
$instance_type = getenv('APIGEE_EDGE_INSTANCE_TYPE');
if (!empty($instance_type) && $instance_type === EdgeKeyTypeInterface::INSTANCE_TYPE_HYBRID) {
$this->markTestSkipped('This test suite is expecting a PUBLIC instance type.');
}
parent::setUp();
$this->initTestEnv();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

namespace Drupal\Tests\apigee_edge\FunctionalJavascript;

use Drupal\apigee_edge\Plugin\EdgeKeyTypeInterface;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
use Drupal\Tests\apigee_edge\Traits\ApigeeEdgeFunctionalTestTrait;

Expand All @@ -40,6 +41,11 @@ abstract class ApigeeEdgeFunctionalJavascriptTestBase extends WebDriverTestBase
* {@inheritdoc}
*/
protected function setUp(): void {
// Skipping the test if instance type is Public.
$instance_type = getenv('APIGEE_EDGE_INSTANCE_TYPE');
if (!empty($instance_type) && $instance_type === EdgeKeyTypeInterface::INSTANCE_TYPE_HYBRID) {
$this->markTestSkipped('This test suite is expecting a PUBLIC instance type.');
}
parent::setUp();
$this->initTestEnv();
}
Expand All @@ -58,9 +64,7 @@ public function createScreenshot($filename_prefix = '', $set_background_color =
}
/** @var \Drupal\Core\Database\Connection $database */
$database = $this->container->get('database');
// @todo tablePrefix() is deprecated in Drupal 10.1
// @phpstan-ignore-next-line
$test_id = str_replace('test', '', $database->tablePrefix());
$test_id = str_replace('test', '', $database->getPrefix());
// Add table suffix (test id) to the file name and ensure the generated
// file name is unique.
$filename = \Drupal::service('file_system')
Expand Down
42 changes: 42 additions & 0 deletions tests/src/Kernel/ApigeeEdgeKernelTestBase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

/**
* Copyright 2023 Google Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 2 as published by the
* Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

namespace Drupal\Tests\apigee_edge\Kernel;

use Drupal\apigee_edge\Plugin\EdgeKeyTypeInterface;
use Drupal\KernelTests\KernelTestBase;

/**
* Base class for kernel tests.
*/
abstract class ApigeeEdgeKernelTestBase extends KernelTestBase {

/**
* {@inheritdoc}
*/
protected function setUp(): void {
// Skipping the test if instance type is hybrid.
$instance_type = getenv('APIGEE_EDGE_INSTANCE_TYPE');
if (!empty($instance_type) && $instance_type === EdgeKeyTypeInterface::INSTANCE_TYPE_HYBRID) {
$this->markTestSkipped('This test suite is expecting a PUBLIC instance type.');
}
parent::setUp();
}

}
4 changes: 2 additions & 2 deletions tests/src/Kernel/Entity/AppWarningsCheckerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
use Drupal\apigee_edge\Entity\ApiProduct;
use Drupal\apigee_edge\Entity\Developer;
use Drupal\apigee_edge\Entity\DeveloperApp;
use Drupal\KernelTests\KernelTestBase;
use Drupal\Tests\apigee_edge\Kernel\ApigeeEdgeKernelTestBase;
use Drupal\Tests\apigee_edge\Kernel\ApigeeEdgeKernelTestTrait;
use Drupal\Tests\apigee_edge\Traits\CredsUtilsTrait;
use Drupal\Tests\apigee_mock_api_client\Traits\ApigeeMockApiClientHelperTrait;
Expand All @@ -39,7 +39,7 @@
* @group apigee_edge
* @group apigee_edge_kernel
*/
class AppWarningsCheckerTest extends KernelTestBase {
class AppWarningsCheckerTest extends ApigeeEdgeKernelTestBase {

use ApigeeMockApiClientHelperTrait, ApigeeEdgeKernelTestTrait, UserCreationTrait, CredsUtilsTrait;

Expand Down
4 changes: 2 additions & 2 deletions tests/src/Kernel/Entity/ListBuilder/AppListBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
use Drupal\apigee_edge\Entity\Developer;
use Drupal\apigee_edge\Entity\DeveloperApp;
use Drupal\Component\Utility\Html;
use Drupal\KernelTests\KernelTestBase;
use Drupal\Tests\apigee_edge\Kernel\ApigeeEdgeKernelTestBase;
use Drupal\Tests\apigee_edge\Kernel\ApigeeEdgeKernelTestTrait;
use Drupal\Tests\apigee_edge\Traits\CredsUtilsTrait;
use Drupal\Tests\apigee_mock_api_client\Traits\ApigeeMockApiClientHelperTrait;
Expand All @@ -41,7 +41,7 @@
* @group apigee_edge
* @group apigee_edge_kernel
*/
class AppListBuilderTest extends KernelTestBase {
class AppListBuilderTest extends ApigeeEdgeKernelTestBase {

use ApigeeMockApiClientHelperTrait, ApigeeEdgeKernelTestTrait, UserCreationTrait, CredsUtilsTrait;

Expand Down
4 changes: 2 additions & 2 deletions tests/src/Kernel/Entity/ListBuilder/EntityListBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

use Drupal\Core\Entity\Entity\EntityViewMode;
use Drupal\Core\Url;
use Drupal\KernelTests\KernelTestBase;
use Drupal\Tests\apigee_edge\Kernel\ApigeeEdgeKernelTestBase;
use Drupal\Tests\apigee_edge\Kernel\ApigeeEdgeKernelTestTrait;
use Drupal\Tests\apigee_mock_api_client\Traits\ApigeeMockApiClientHelperTrait;
use Drupal\Tests\user\Traits\UserCreationTrait;
Expand All @@ -35,7 +35,7 @@
* @group apigee_edge
* @group apigee_edge_kernel
*/
class EntityListBuilderTest extends KernelTestBase {
class EntityListBuilderTest extends ApigeeEdgeKernelTestBase {

use ApigeeMockApiClientHelperTrait, ApigeeEdgeKernelTestTrait, UserCreationTrait;

Expand Down
4 changes: 2 additions & 2 deletions tests/src/Kernel/TestFrameworkKernelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

use Drupal\apigee_edge\Entity\Developer;
use Drupal\Core\Form\FormState;
use Drupal\KernelTests\KernelTestBase;
use Drupal\Tests\apigee_edge\Kernel\ApigeeEdgeKernelTestBase;
use Drupal\Tests\apigee_mock_api_client\Traits\ApigeeMockApiClientHelperTrait;
use Drupal\Tests\user\Traits\UserCreationTrait;
use GuzzleHttp\Psr7\Response;
Expand All @@ -33,7 +33,7 @@
* @group apigee_edge
* @group apigee_edge_kernel
*/
class TestFrameworkKernelTest extends KernelTestBase {
class TestFrameworkKernelTest extends ApigeeEdgeKernelTestBase {

use ApigeeMockApiClientHelperTrait;
use UserCreationTrait;
Expand Down
2 changes: 1 addition & 1 deletion tests/src/Kernel/UserAgentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected function setUp(): void {
*/
public function testUserAgentWithoutMonetization() {
// apigee_edge module info.
$infoParser = new InfoParser();
$infoParser = new InfoParser($this->root);
$this->edgeModuleInfo = $infoParser->parse(\Drupal::service('module_handler')->getModule('apigee_edge')->getPathname());
if (!isset($this->edgeModuleInfo['version'])) {
$this->edgeModuleInfo['version'] = '2.x-dev';
Expand Down
4 changes: 2 additions & 2 deletions tests/src/Kernel/Util/ApigeeEdgeManagementCliServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\DependencyInjection\ServiceModifierInterface;
use Drupal\Core\Utility\Error;
use Drupal\KernelTests\KernelTestBase;
use Drupal\Tests\apigee_edge\Kernel\ApigeeEdgeKernelTestBase;
use Drupal\Tests\apigee_mock_api_client\Traits\ApigeeMockApiClientHelperTrait;

/**
Expand All @@ -37,7 +37,7 @@
* @group apigee_edge
* @group apigee_edge_kernel
*/
class ApigeeEdgeManagementCliServiceTest extends KernelTestBase implements ServiceModifierInterface {
class ApigeeEdgeManagementCliServiceTest extends ApigeeEdgeKernelTestBase implements ServiceModifierInterface {

use ApigeeMockApiClientHelperTrait;

Expand Down

0 comments on commit 523fad7

Please sign in to comment.