From 256c6a63b1a6a37141bb94764b8b4f638a383a90 Mon Sep 17 00:00:00 2001 From: Aleksandar Sabo Date: Mon, 27 Jan 2025 11:12:31 +0100 Subject: [PATCH 1/7] Add PHP 8.4 to test matrix --- .github/workflows/RavenClient.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/RavenClient.yml b/.github/workflows/RavenClient.yml index cf348f48..2128a8a0 100644 --- a/.github/workflows/RavenClient.yml +++ b/.github/workflows/RavenClient.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: - php-versions: [ "8.2", "8.3"] + php-versions: [ "8.2", "8.3", "8.4"] serverVersion: [ "5.4" ] fail-fast: false From 5163952f2fe74fcef4b3e4dd292de68fd5a941c5 Mon Sep 17 00:00:00 2001 From: Aleksandar Sabo Date: Mon, 27 Jan 2025 11:22:27 +0100 Subject: [PATCH 2/7] Add Raven 7.0 to test matrix --- .github/workflows/RavenClient.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/RavenClient.yml b/.github/workflows/RavenClient.yml index 2128a8a0..74c35757 100644 --- a/.github/workflows/RavenClient.yml +++ b/.github/workflows/RavenClient.yml @@ -14,7 +14,7 @@ jobs: strategy: matrix: php-versions: [ "8.2", "8.3", "8.4"] - serverVersion: [ "5.4" ] + serverVersion: [ "5.4", "6.2", "7.0" ] fail-fast: false env: From 3e5bc4e6f680953f0d1e394d597101b12df7f4e7 Mon Sep 17 00:00:00 2001 From: Aleksandar Sabo Date: Tue, 28 Jan 2025 15:49:15 +0100 Subject: [PATCH 3/7] Disable failing tests for RDB v6 --- tests/Infrastructure/TestRunGuard.php | 47 ++++++++++++++++++- .../Issues/RavenDB903Test/RavenDB903Test.php | 5 ++ .../_MoreLikeThisTest/MoreLikeThisTest.php | 5 ++ tests/Test/Client/RevisionsTest.php | 1 + .../BoundingBoxIndexTest.php | 3 ++ .../_SimonBartlettTest/SimonBartlettTest.php | 5 ++ .../_SpatialSearchTest/SpatialSearchTest.php | 3 ++ tests/Test/Client/_QueryTest/QueryTest.php | 5 ++ .../RavenDB_12030Test/RavenDB_12030Test.php | 5 ++ .../RavenDB_13682Test/RavenDB_13682Test.php | 5 ++ .../RavenDB_8328Test/RavenDB_8328Test.php | 3 ++ tests/Test/Issues/RavenDB_8355Test.php | 5 ++ .../RavenDB_9745Test/RavenDB_9745Test.php | 3 ++ .../_HighlightesTest/HighlightesTest.php | 3 ++ .../_SuggestionsTest/SuggestionsTest.php | 7 +++ 15 files changed, 104 insertions(+), 1 deletion(-) diff --git a/tests/Infrastructure/TestRunGuard.php b/tests/Infrastructure/TestRunGuard.php index 25e6e0d6..4159f499 100644 --- a/tests/Infrastructure/TestRunGuard.php +++ b/tests/Infrastructure/TestRunGuard.php @@ -3,12 +3,16 @@ namespace tests\RavenDB\Infrastructure; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Warning; class TestRunGuard { public static string $ENV_RAVEN_LICENSE = "RAVEN_LICENSE"; public static string $SERVER_VERSION = "SERVER_VERSION"; + public static int $MAJOR_VERSION = 0; + public static int $MINOR_VERSION = 1; + public static function disableTestIfLicenseNotAvailable(TestCase $testCase): void { $ravenLicense = getenv(self::$ENV_RAVEN_LICENSE); @@ -26,7 +30,48 @@ public static function disableTestForRaven52(TestCase $testCase): void public static function isServerVersion52(): bool { + $versionString = self::getServerVersionAsString(); + + return $versionString == '5.2'; + } + + public static function disableTestForRaven6AndLater(TestCase $testCase): void + { + if (self::isServerVersionGreaterOrEqualThan60()) { + $testCase->markTestSkipped("Test disabled for RavenDB version greater than 6.0"); + } + } + + public static function isServerVersionGreaterOrEqualThan60(): bool + { + $version = self::getServerVersion(); + return intval($version[self::$MAJOR_VERSION]) >= 6; + } + + public static function getServerVersionAsString(): string + { + // Server version saved in .env variable in a format: MAJOR.MINOR, for example: "5.4" $serverVersion = getenv(self::$SERVER_VERSION); - return $serverVersion == '5.2'; + + if (!$serverVersion) { + return throw new Warning('RavenDB SERVER_VERSION is not set in .env variables'); + } + + return $serverVersion; } + + /** + * Version information in array + * - $version[0] - major version + * - $version[1] - minor version + * + * @return array with information about major and minor version + */ + public static function getServerVersion(): array + { + $versionString = self::getServerVersionAsString(); + + return explode('.', $versionString); + } + } diff --git a/tests/Test/Client/Issues/RavenDB903Test/RavenDB903Test.php b/tests/Test/Client/Issues/RavenDB903Test/RavenDB903Test.php index 860f67ca..1128bf81 100644 --- a/tests/Test/Client/Issues/RavenDB903Test/RavenDB903Test.php +++ b/tests/Test/Client/Issues/RavenDB903Test/RavenDB903Test.php @@ -4,6 +4,7 @@ use RavenDB\Documents\Session\DocumentQueryInterface; use RavenDB\Documents\Session\DocumentSessionInterface; +use tests\RavenDB\Infrastructure\TestRunGuard; use tests\RavenDB\RemoteTestBase; use tests\RavenDB\Test\Client\Issues\RavenDB903Test\Entity\Product; use tests\RavenDB\Test\Client\Issues\RavenDB903Test\Entity\TestIndex; @@ -12,6 +13,8 @@ class RavenDB903Test extends RemoteTestBase { public function test1(): void { + TestRunGuard::disableTestForRaven6AndLater($this); + $this->doTest( function (DocumentSessionInterface $session): DocumentQueryInterface { return $session->advanced()->documentQuery(Product::class, TestIndex::class) @@ -24,6 +27,8 @@ function (DocumentSessionInterface $session): DocumentQueryInterface { public function test2(): void { + TestRunGuard::disableTestForRaven6AndLater($this); + $this->doTest( function (DocumentSessionInterface $session): DocumentQueryInterface { return $session->advanced()->documentQuery(Product::class, TestIndex::class) diff --git a/tests/Test/Client/MoreLikeThis/_MoreLikeThisTest/MoreLikeThisTest.php b/tests/Test/Client/MoreLikeThis/_MoreLikeThisTest/MoreLikeThisTest.php index 00339011..459d7888 100644 --- a/tests/Test/Client/MoreLikeThis/_MoreLikeThisTest/MoreLikeThisTest.php +++ b/tests/Test/Client/MoreLikeThis/_MoreLikeThisTest/MoreLikeThisTest.php @@ -5,6 +5,7 @@ use RavenDB\Documents\DocumentStoreInterface; use RavenDB\Documents\Queries\MoreLikeThis\MoreLikeThisOptions; use RavenDB\Documents\Queries\MoreLikeThis\MoreLikeThisStopWords; +use tests\RavenDB\Infrastructure\TestRunGuard; use tests\RavenDB\RemoteTestBase; class MoreLikeThisTest extends RemoteTestBase @@ -384,6 +385,8 @@ public function test_can_Use_Min_Doc_Freq_Param(): void public function test_can_Use_Boost_Param(): void { + TestRunGuard::disableTestForRaven6AndLater($this); + $store = $this->getDocumentStore(); try { $key = "data/1-A"; @@ -535,6 +538,8 @@ public function testCanMakeDynamicDocumentQueries(): void public function testCanMakeDynamicDocumentQueriesWithComplexProperties(): void { + TestRunGuard::disableTestForRaven6AndLater($this); + $store = $this->getDocumentStore(); try { (new ComplexDataIndex())->execute($store); diff --git a/tests/Test/Client/RevisionsTest.php b/tests/Test/Client/RevisionsTest.php index 78a7b2da..df53d888 100644 --- a/tests/Test/Client/RevisionsTest.php +++ b/tests/Test/Client/RevisionsTest.php @@ -92,6 +92,7 @@ public function testRevisions(): void public function testCanListRevisionsBin(): void { TestRunGuard::disableTestForRaven52($this); + TestRunGuard::disableTestForRaven6AndLater($this); $store = $this->getDocumentStore(); try { diff --git a/tests/Test/Client/Spatial/_BoundingBoxIndexTest/BoundingBoxIndexTest.php b/tests/Test/Client/Spatial/_BoundingBoxIndexTest/BoundingBoxIndexTest.php index f21ad280..b19969b2 100644 --- a/tests/Test/Client/Spatial/_BoundingBoxIndexTest/BoundingBoxIndexTest.php +++ b/tests/Test/Client/Spatial/_BoundingBoxIndexTest/BoundingBoxIndexTest.php @@ -2,12 +2,15 @@ namespace tests\RavenDB\Test\Client\Spatial\_BoundingBoxIndexTest; +use tests\RavenDB\Infrastructure\TestRunGuard; use tests\RavenDB\RemoteTestBase; class BoundingBoxIndexTest extends RemoteTestBase { public function testBoundingBoxTest(): void { + TestRunGuard::disableTestForRaven6AndLater($this); + $polygon = "POLYGON ((0 0, 0 5, 1 5, 1 1, 5 1, 5 5, 6 5, 6 0, 0 0))"; $rectangle1 = "2 2 4 4"; $rectangle2 = "6 6 10 10"; diff --git a/tests/Test/Client/Spatial/_SimonBartlettTest/SimonBartlettTest.php b/tests/Test/Client/Spatial/_SimonBartlettTest/SimonBartlettTest.php index 88e63315..0bf924fd 100644 --- a/tests/Test/Client/Spatial/_SimonBartlettTest/SimonBartlettTest.php +++ b/tests/Test/Client/Spatial/_SimonBartlettTest/SimonBartlettTest.php @@ -3,12 +3,15 @@ namespace tests\RavenDB\Test\Client\Spatial\_SimonBartlettTest; use RavenDB\Documents\Indexes\Spatial\SpatialRelation; +use tests\RavenDB\Infrastructure\TestRunGuard; use tests\RavenDB\RemoteTestBase; class SimonBartlettTest extends RemoteTestBase { public function testLineStringsShouldIntersect(): void { + TestRunGuard::disableTestForRaven6AndLater($this); + $store = $this->getDocumentStore(); try { $store->executeIndex(new GeoIndex()); @@ -50,6 +53,8 @@ public function testLineStringsShouldIntersect(): void public function testCirclesShouldNotIntersect(): void { + TestRunGuard::disableTestForRaven6AndLater($this); + $store = $this->getDocumentStore(); try { $store->executeIndex(new GeoIndex()); diff --git a/tests/Test/Client/Spatial/_SpatialSearchTest/SpatialSearchTest.php b/tests/Test/Client/Spatial/_SpatialSearchTest/SpatialSearchTest.php index 228e8a7f..6a0433a0 100644 --- a/tests/Test/Client/Spatial/_SpatialSearchTest/SpatialSearchTest.php +++ b/tests/Test/Client/Spatial/_SpatialSearchTest/SpatialSearchTest.php @@ -6,6 +6,7 @@ use RavenDB\Documents\Queries\Query; use RavenDB\Documents\Session\QueryStatistics; use RavenDB\Utils\DateUtils; +use tests\RavenDB\Infrastructure\TestRunGuard; use tests\RavenDB\RemoteTestBase; class SpatialSearchTest extends RemoteTestBase @@ -78,6 +79,8 @@ public function test_can_do_spatial_search_with_client_api3(): void public function test_can_do_spatial_search_with_client_api_within_given_capacity(): void { + TestRunGuard::disableTestForRaven6AndLater($this); + $store = $this->getDocumentStore(); try { (new SpatialIdx())->execute($store); diff --git a/tests/Test/Client/_QueryTest/QueryTest.php b/tests/Test/Client/_QueryTest/QueryTest.php index 1ad11c8d..892e82be 100644 --- a/tests/Test/Client/_QueryTest/QueryTest.php +++ b/tests/Test/Client/_QueryTest/QueryTest.php @@ -20,6 +20,7 @@ use RavenDB\Utils\StringUtils; use tests\RavenDB\Infrastructure\Entity\User; use tests\RavenDB\Infrastructure\Entity\Order; +use tests\RavenDB\Infrastructure\TestRunGuard; use tests\RavenDB\RemoteTestBase; use tests\RavenDB\Test\Client\_QueryTest\Entity\Article; use tests\RavenDB\Test\Client\_QueryTest\Entity\Dog; @@ -764,6 +765,8 @@ public function testParametersInRawQuery(): void public function testQueryLucene(): void { + TestRunGuard::disableTestForRaven6AndLater($this); + $store = $this->getDocumentStore(); try { $this->addUsers($store); @@ -1031,6 +1034,8 @@ public function testQueryWhereExists(): void public function testQueryWithBoost(): void { + TestRunGuard::disableTestForRaven6AndLater($this); + $store = $this->getDocumentStore(); try { $this->addUsers($store); diff --git a/tests/Test/Issues/RavenDB_12030Test/RavenDB_12030Test.php b/tests/Test/Issues/RavenDB_12030Test/RavenDB_12030Test.php index 5705e629..00891f76 100644 --- a/tests/Test/Issues/RavenDB_12030Test/RavenDB_12030Test.php +++ b/tests/Test/Issues/RavenDB_12030Test/RavenDB_12030Test.php @@ -2,6 +2,7 @@ namespace tests\RavenDB\Test\Issues\RavenDB_12030Test; +use tests\RavenDB\Infrastructure\TestRunGuard; use tests\RavenDB\RemoteTestBase; use tests\RavenDB\Infrastructure\Entity\Company; @@ -9,6 +10,8 @@ class RavenDB_12030Test extends RemoteTestBase { public function testSimpleFuzzy(): void { + TestRunGuard::disableTestForRaven6AndLater($this); + $store = $this->getDocumentStore(); try { @@ -68,6 +71,8 @@ public function testSimpleFuzzy(): void public function testSimpleProximity(): void { + TestRunGuard::disableTestForRaven6AndLater($this); + $store = $this->getDocumentStore(); try { (new Fox_Search())->execute($store); diff --git a/tests/Test/Issues/RavenDB_13682Test/RavenDB_13682Test.php b/tests/Test/Issues/RavenDB_13682Test/RavenDB_13682Test.php index a9afd139..a72f4618 100644 --- a/tests/Test/Issues/RavenDB_13682Test/RavenDB_13682Test.php +++ b/tests/Test/Issues/RavenDB_13682Test/RavenDB_13682Test.php @@ -9,6 +9,7 @@ use RavenDB\Documents\Smuggler\DatabaseItemTypeSet; use tests\RavenDB\Infrastructure\CreateSampleDataOperation; use tests\RavenDB\Infrastructure\Entity\Order; +use tests\RavenDB\Infrastructure\TestRunGuard; use tests\RavenDB\RemoteTestBase; class RavenDB_13682Test extends RemoteTestBase @@ -108,6 +109,8 @@ public function testCanQueryByRoundedSpatialRanges(): void public function testCanUseDynamicQueryOrderBySpatial_WithAlias(): void { + TestRunGuard::disableTestForRaven6AndLater($this); + $store = $this->getDocumentStore(); try { @@ -141,6 +144,8 @@ public function testCanUseDynamicQueryOrderBySpatial_WithAlias(): void public function testCanGetDistanceFromSpatialQuery(): void { + TestRunGuard::disableTestForRaven6AndLater($this); + $store = $this->getDocumentStore(); try { $set = new DatabaseItemTypeSet(); diff --git a/tests/Test/Issues/RavenDB_8328Test/RavenDB_8328Test.php b/tests/Test/Issues/RavenDB_8328Test/RavenDB_8328Test.php index 8a4d4067..130d1c5d 100644 --- a/tests/Test/Issues/RavenDB_8328Test/RavenDB_8328Test.php +++ b/tests/Test/Issues/RavenDB_8328Test/RavenDB_8328Test.php @@ -5,12 +5,15 @@ use RavenDB\Documents\Queries\Spatial\PointField; use RavenDB\Documents\Queries\Spatial\WktField; use RavenDB\Documents\Session\QueryStatistics; +use tests\RavenDB\Infrastructure\TestRunGuard; use tests\RavenDB\RemoteTestBase; class RavenDB_8328Test extends RemoteTestBase { public function testSpatialOnAutoIndex(): void { + TestRunGuard::disableTestForRaven6AndLater($this); + $store = $this->getDocumentStore(); try { $session = $store->openSession(); diff --git a/tests/Test/Issues/RavenDB_8355Test.php b/tests/Test/Issues/RavenDB_8355Test.php index 52431925..2a9d4208 100644 --- a/tests/Test/Issues/RavenDB_8355Test.php +++ b/tests/Test/Issues/RavenDB_8355Test.php @@ -11,6 +11,7 @@ use RavenDB\Exceptions\Documents\Sorters\SorterDoesNotExistException; use RavenDB\Exceptions\RavenException; use tests\RavenDB\Infrastructure\Entity\Company; +use tests\RavenDB\Infrastructure\TestRunGuard; use tests\RavenDB\RemoteTestBase; use Throwable; @@ -64,6 +65,8 @@ class RavenDB_8355Test extends RemoteTestBase public function testCanUseCustomSorter(): void { + TestRunGuard::disableTestForRaven6AndLater($this); + $sorterDefinition = new SorterDefinition(); $sorterDefinition->setName("MySorter"); $sorterDefinition->setCode(self::$sorterCode); @@ -97,6 +100,8 @@ public function testCanUseCustomSorter(): void public function testCanUseCustomSorterWithOperations(): void { + TestRunGuard::disableTestForRaven6AndLater($this); + $store = $this->getDocumentStore(); try { $session = $store->openSession(); diff --git a/tests/Test/Issues/RavenDB_9745Test/RavenDB_9745Test.php b/tests/Test/Issues/RavenDB_9745Test/RavenDB_9745Test.php index 85a8a54d..c8af2d85 100644 --- a/tests/Test/Issues/RavenDB_9745Test/RavenDB_9745Test.php +++ b/tests/Test/Issues/RavenDB_9745Test/RavenDB_9745Test.php @@ -5,12 +5,15 @@ use RavenDB\Documents\Queries\Explanation\ExplanationOptions; use RavenDB\Documents\Queries\Explanation\Explanations; use tests\RavenDB\Infrastructure\Entity\Company; +use tests\RavenDB\Infrastructure\TestRunGuard; use tests\RavenDB\RemoteTestBase; class RavenDB_9745Test extends RemoteTestBase { public function testExplain(): void { + TestRunGuard::disableTestForRaven6AndLater($this); + $store = $this->getDocumentStore(); try { diff --git a/tests/Test/Querying/_HighlightesTest/HighlightesTest.php b/tests/Test/Querying/_HighlightesTest/HighlightesTest.php index d100060c..c47cd7ee 100644 --- a/tests/Test/Querying/_HighlightesTest/HighlightesTest.php +++ b/tests/Test/Querying/_HighlightesTest/HighlightesTest.php @@ -5,12 +5,15 @@ use RavenDB\Documents\Queries\Highlighting\HighlightingOptions; use RavenDB\Documents\Queries\Highlighting\Highlightings; use RavenDB\Documents\Queries\Query; +use tests\RavenDB\Infrastructure\TestRunGuard; use tests\RavenDB\RemoteTestBase; class HighlightesTest extends RemoteTestBase { public function testSearchWithHighlights(): void { + TestRunGuard::disableTestForRaven6AndLater($this); + $q = "session"; $store = $this->getDocumentStore(); diff --git a/tests/Test/Suggestions/_SuggestionsTest/SuggestionsTest.php b/tests/Test/Suggestions/_SuggestionsTest/SuggestionsTest.php index 964698d8..b6c965fc 100644 --- a/tests/Test/Suggestions/_SuggestionsTest/SuggestionsTest.php +++ b/tests/Test/Suggestions/_SuggestionsTest/SuggestionsTest.php @@ -10,6 +10,7 @@ use RavenDB\Documents\Queries\Suggestions\StringDistanceTypes; use RavenDB\Documents\Queries\Suggestions\SuggestionOptions; use RavenDB\Documents\Queries\Suggestions\SuggestionSortMode; +use tests\RavenDB\Infrastructure\TestRunGuard; use tests\RavenDB\RemoteTestBase; use tests\RavenDB\Test\Client\Indexing\_IndexesFromClientTest\Users_ByName; @@ -52,6 +53,8 @@ public function setupStore(?DocumentStoreInterface $store): void public function testExactMatch(): void { + TestRunGuard::disableTestForRaven6AndLater($this); + $store = $this->getDocumentStore(); try { $this->setupStore($store); @@ -153,6 +156,8 @@ public function test_usingLinq_Multiple_words(): void public function testWithTypo(): void { + TestRunGuard::disableTestForRaven6AndLater($this); + $store = $this->getDocumentStore(); try { $this->setupStore($store); @@ -182,6 +187,8 @@ public function testWithTypo(): void public function testCanGetSuggestions(): void { + TestRunGuard::disableTestForRaven6AndLater($this); + $store = $this->getDocumentStore(); try { (new Users_ByName())->execute($store); From 33a7901ef32312bc284e392a2b833771dd8323e3 Mon Sep 17 00:00:00 2001 From: Aleksandar Sabo Date: Tue, 28 Jan 2025 15:54:08 +0100 Subject: [PATCH 4/7] Update branch check --- .github/workflows/RavenClient.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/RavenClient.yml b/.github/workflows/RavenClient.yml index 74c35757..f58fed3d 100644 --- a/.github/workflows/RavenClient.yml +++ b/.github/workflows/RavenClient.yml @@ -3,9 +3,9 @@ on: schedule: - cron: "0 10 * * 6" push: - branches: [ v5.4 ] + branches: [ v6.0 ] pull_request: - branches: [ v5.4 ] + branches: [ v6.0 ] jobs: build: @@ -14,7 +14,7 @@ jobs: strategy: matrix: php-versions: [ "8.2", "8.3", "8.4"] - serverVersion: [ "5.4", "6.2", "7.0" ] + serverVersion: [ "6.2", "7.0" ] fail-fast: false env: From c4e6b542d2de235dbfdc1a26611e79ec095a2df7 Mon Sep 17 00:00:00 2001 From: Aleksandar Sabo Date: Tue, 28 Jan 2025 17:50:18 +0100 Subject: [PATCH 5/7] Disable tests in v7 that require license if license is not provided --- .github/workflows/RavenClient.yml | 6 ++-- tests/Infrastructure/TestRunGuard.php | 28 +++++++++++++++++++ tests/Test/Client/HttpsTest.php | 2 +- tests/Test/Client/RevisionsTest.php | 22 +++++++++++++++ tests/Test/ForceRevisionCreationTest.php | 5 +++- tests/Test/Issues/RavenDB_11440Test.php | 3 ++ tests/Test/Issues/RavenDB_13456Test.php | 3 ++ tests/Test/Issues/RavenDB_13735Test.php | 3 ++ tests/Test/Issues/RavenDB_16328Test.php | 3 ++ .../RavenDB_16328_AnalyzersTest.php | 3 ++ .../Server/ExpirationConfigurationTest.php | 3 ++ 11 files changed, 76 insertions(+), 5 deletions(-) diff --git a/.github/workflows/RavenClient.yml b/.github/workflows/RavenClient.yml index f58fed3d..b122b6e2 100644 --- a/.github/workflows/RavenClient.yml +++ b/.github/workflows/RavenClient.yml @@ -3,9 +3,9 @@ on: schedule: - cron: "0 10 * * 6" push: - branches: [ v6.0 ] + branches: [ v5.4, v6.0 ] pull_request: - branches: [ v6.0 ] + branches: [ v5.4, v6.0 ] jobs: build: @@ -14,7 +14,7 @@ jobs: strategy: matrix: php-versions: [ "8.2", "8.3", "8.4"] - serverVersion: [ "6.2", "7.0" ] + serverVersion: [ "5.4", "6.2", "7.0" ] fail-fast: false env: diff --git a/tests/Infrastructure/TestRunGuard.php b/tests/Infrastructure/TestRunGuard.php index 4159f499..92542eca 100644 --- a/tests/Infrastructure/TestRunGuard.php +++ b/tests/Infrastructure/TestRunGuard.php @@ -21,6 +21,21 @@ public static function disableTestIfLicenseNotAvailable(TestCase $testCase): voi } } + public static function disableTestIfLicenseNotAvailableForV6(TestCase $testCase): void + { + $ravenLicense = getenv(self::$ENV_RAVEN_LICENSE); + if (!empty($ravenLicense)) { + return; + } + + $version = self::getServerVersion(); + if ($version[self::$MAJOR_VERSION] < 6) { + return; + } + + $testCase->markTestSkipped("Test disabled on Pull Request. License not available."); + } + public static function disableTestForRaven52(TestCase $testCase): void { if (self::isServerVersion52()) { @@ -42,6 +57,19 @@ public static function disableTestForRaven6AndLater(TestCase $testCase): void } } + public static function isServerVersionGreaterOrEqualThan70(): bool + { + $version = self::getServerVersion(); + return intval($version[self::$MAJOR_VERSION]) >= 7; + } + + public static function disableTestForRaven7AndLater(TestCase $testCase): void + { + if (self::isServerVersionGreaterOrEqualThan70()) { + $testCase->markTestSkipped("Test disabled for RavenDB version greater than 7.0"); + } + } + public static function isServerVersionGreaterOrEqualThan60(): bool { $version = self::getServerVersion(); diff --git a/tests/Test/Client/HttpsTest.php b/tests/Test/Client/HttpsTest.php index bf9794bb..903a98a0 100644 --- a/tests/Test/Client/HttpsTest.php +++ b/tests/Test/Client/HttpsTest.php @@ -232,7 +232,7 @@ public function testShouldThrowAuthorizationExceptionWhenNotAuthorized() { $session = $storeWithOutCert->openSession(); try { $this->expectException(AuthorizationException::class); - $this->expectErrorMessage('Forbidden access to '); + $this->expectExceptionMessage('Forbidden access to '); $user1 = $session->load(User::class, "users/1"); diff --git a/tests/Test/Client/RevisionsTest.php b/tests/Test/Client/RevisionsTest.php index df53d888..b19ee279 100644 --- a/tests/Test/Client/RevisionsTest.php +++ b/tests/Test/Client/RevisionsTest.php @@ -25,6 +25,8 @@ class RevisionsTest extends RemoteTestBase { public function testRevisions(): void { + TestRunGuard::disableTestIfLicenseNotAvailableForV6($this); + $store = $this->getDocumentStore(); try { $this->setupRevisions($store, false, 4); @@ -130,6 +132,8 @@ public function testCanListRevisionsBin(): void public function testCanGetRevisionsByChangeVectors(): void { + TestRunGuard::disableTestIfLicenseNotAvailableForV6($this); + $store = $this->getDocumentStore(); try { $id = "users/1"; @@ -331,6 +335,8 @@ public function testCanGetNonExistingRevisionsByChangeVectorAsyncLazily(): void public function testCanGetRevisionsByChangeVectorsLazily(): void { + TestRunGuard::disableTestIfLicenseNotAvailableForV6($this); + $store = $this->getDocumentStore(); try { $id = "users/1"; @@ -388,6 +394,8 @@ public function testCanGetRevisionsByChangeVectorsLazily(): void public function testCanGetForLazily(): void { + TestRunGuard::disableTestIfLicenseNotAvailableForV6($this); + $store = $this->getDocumentStore(); try { $id = "users/1"; @@ -458,6 +466,8 @@ public function testCanGetForLazily(): void public function testCanGetRevisionsByIdAndTimeLazily(): void { + TestRunGuard::disableTestIfLicenseNotAvailableForV6($this); + $store = $this->getDocumentStore(); try { $id = "users/1"; @@ -511,6 +521,8 @@ public function testCanGetRevisionsByIdAndTimeLazily(): void public function testCanGetMetadataForLazily(): void { + TestRunGuard::disableTestIfLicenseNotAvailableForV6($this); + $store = $this->getDocumentStore(); try { $id = "users/1"; @@ -572,6 +584,8 @@ public function testCanGetMetadataForLazily(): void public function testCanGetRevisionsByChangeVectorLazily(): void { + TestRunGuard::disableTestIfLicenseNotAvailableForV6($this); + $store = $this->getDocumentStore(); try { @@ -647,6 +661,8 @@ public function testCanGetRevisionsByChangeVectorLazily(): void public function testCanGetAllRevisionsForDocument_UsingStoreOperation(): void { + TestRunGuard::disableTestIfLicenseNotAvailableForV6($this); + $company = new Company(); $company->setName("Company Name"); $store = $this->getDocumentStore(); @@ -685,6 +701,8 @@ public function testCanGetAllRevisionsForDocument_UsingStoreOperation(): void public function testCanGetRevisionsWithPaging_UsingStoreOperation(): void { + TestRunGuard::disableTestIfLicenseNotAvailableForV6($this); + $store = $this->getDocumentStore(); try { $this->setupRevisions($store, false, 123); @@ -750,6 +768,8 @@ public function testCanGetRevisionsWithPaging_UsingStoreOperation(): void public function testCanGetRevisionsWithPaging2_UsingStoreOperation(): void { + TestRunGuard::disableTestIfLicenseNotAvailableForV6($this); + $store = $this->getDocumentStore(); try { $this->setupRevisions($store, false, 100); @@ -794,6 +814,8 @@ public function testCanGetRevisionsWithPaging2_UsingStoreOperation(): void public function testCanGetRevisionsCountFor(): void { + TestRunGuard::disableTestIfLicenseNotAvailableForV6($this); + $company = new Company(); $company->setName("Company Name"); diff --git a/tests/Test/ForceRevisionCreationTest.php b/tests/Test/ForceRevisionCreationTest.php index f3b91619..b465bacc 100644 --- a/tests/Test/ForceRevisionCreationTest.php +++ b/tests/Test/ForceRevisionCreationTest.php @@ -10,6 +10,7 @@ use RavenDB\Exceptions\IllegalStateException; use RavenDB\Exceptions\RavenException; use tests\RavenDB\Infrastructure\Entity\Company; +use tests\RavenDB\Infrastructure\TestRunGuard; use tests\RavenDB\RemoteTestBase; use Throwable; @@ -167,7 +168,7 @@ public function testCannotForceRevisionCreationForNewDocumentBeforeSavingToServe $this->assertInstanceOf(RavenException::class, $exception); $this->assertStringContainsString("Can't force revision creation - the document was not saved on the server yet", $exception->getMessage()); }; - + $revisionsCount = count($session->advanced()->revisions()->getFor(Company::class, $company->getId())); $this->assertEquals(0, $revisionsCount); } finally { @@ -459,6 +460,8 @@ public function testForceRevisionCreationAcrossMultipleSessions(): void public function testForceRevisionCreationWhenRevisionConfigurationIsSet(): void { + TestRunGuard::disableTestIfLicenseNotAvailableForV6($this); + $store = $this->getDocumentStore(); try { // Define revisions settings diff --git a/tests/Test/Issues/RavenDB_11440Test.php b/tests/Test/Issues/RavenDB_11440Test.php index 86d8a9fc..31e1a091 100644 --- a/tests/Test/Issues/RavenDB_11440Test.php +++ b/tests/Test/Issues/RavenDB_11440Test.php @@ -9,12 +9,15 @@ use RavenDB\ServerWide\Operations\Logs\SetLogsConfigurationOperation; use RavenDB\ServerWide\Operations\Logs\SetLogsConfigurationParameters; use RavenDB\Type\Duration; +use tests\RavenDB\Infrastructure\TestRunGuard; use tests\RavenDB\RemoteTestBase; class RavenDB_11440Test extends RemoteTestBase { public function testCanGetLogsConfigurationAndChangeMode(): void { + TestRunGuard::disableTestForRaven7AndLater($this); + $store = $this->getDocumentStore(); try { /** @var GetLogsConfigurationResult $configuration */ diff --git a/tests/Test/Issues/RavenDB_13456Test.php b/tests/Test/Issues/RavenDB_13456Test.php index b8c26b74..2cb687dc 100644 --- a/tests/Test/Issues/RavenDB_13456Test.php +++ b/tests/Test/Issues/RavenDB_13456Test.php @@ -3,6 +3,7 @@ namespace tests\RavenDB\Test\Issues; use Exception; +use tests\RavenDB\Infrastructure\TestRunGuard; use Throwable; use tests\RavenDB\RemoteTestBase; use RavenDB\Exceptions\RavenException; @@ -17,6 +18,8 @@ class RavenDB_13456Test extends RemoteTestBase { public function testCanChangeIdentityPartsSeparator(): void { + TestRunGuard::disableTestIfLicenseNotAvailableForV6($this); + $store = $this->getDocumentStore(); try { $session = $store->openSession(); diff --git a/tests/Test/Issues/RavenDB_13735Test.php b/tests/Test/Issues/RavenDB_13735Test.php index e6b6066d..fb1f4ddb 100644 --- a/tests/Test/Issues/RavenDB_13735Test.php +++ b/tests/Test/Issues/RavenDB_13735Test.php @@ -11,6 +11,7 @@ use RavenDB\Utils\DateUtils; use RavenDB\Utils\Stopwatch; use tests\RavenDB\Infrastructure\Entity\User; +use tests\RavenDB\Infrastructure\TestRunGuard; use tests\RavenDB\RemoteTestBase; class RavenDB_13735Test extends RemoteTestBase @@ -26,6 +27,8 @@ private function setupRefresh(DocumentStoreInterface $store): void public function testRefreshWillUpdateDocumentChangeVector(): void { + TestRunGuard::disableTestIfLicenseNotAvailableForV6($this); + $store = $this->getDocumentStore(); try { $this->setupRefresh($store); diff --git a/tests/Test/Issues/RavenDB_16328Test.php b/tests/Test/Issues/RavenDB_16328Test.php index c05f2d36..227f0c8b 100644 --- a/tests/Test/Issues/RavenDB_16328Test.php +++ b/tests/Test/Issues/RavenDB_16328Test.php @@ -8,6 +8,7 @@ use RavenDB\ServerWide\Sorters\DeleteServerWideSorterOperation; use RavenDB\ServerWide\Sorters\PutServerWideSortersOperation; use tests\RavenDB\Infrastructure\Entity\Company; +use tests\RavenDB\Infrastructure\TestRunGuard; use tests\RavenDB\RemoteTestBase; use Throwable; @@ -15,6 +16,8 @@ class RavenDB_16328Test extends RemoteTestBase { public function testCanUseCustomSorter(): void { + TestRunGuard::disableTestIfLicenseNotAvailableForV6($this); + $store = $this->getDocumentStore(); try { $session = $store->openSession(); diff --git a/tests/Test/Issues/RavenDB_16328_AnalyzersTest/RavenDB_16328_AnalyzersTest.php b/tests/Test/Issues/RavenDB_16328_AnalyzersTest/RavenDB_16328_AnalyzersTest.php index 2b4ed51f..371eba72 100644 --- a/tests/Test/Issues/RavenDB_16328_AnalyzersTest/RavenDB_16328_AnalyzersTest.php +++ b/tests/Test/Issues/RavenDB_16328_AnalyzersTest/RavenDB_16328_AnalyzersTest.php @@ -9,6 +9,7 @@ use RavenDB\ServerWide\Operations\Analyzers\DeleteServerWideAnalyzerOperation; use RavenDB\ServerWide\Operations\Analyzers\PutServerWideAnalyzersOperation; use RavenDB\Type\Duration; +use tests\RavenDB\Infrastructure\TestRunGuard; use tests\RavenDB\RemoteTestBase; use Throwable; @@ -36,6 +37,8 @@ class RavenDB_16328_AnalyzersTest extends RemoteTestBase public function testCanUseCustomAnalyzer(): void { + TestRunGuard::disableTestIfLicenseNotAvailableForV6($this); + $store = $this->getDocumentStore(); try { $analyzerName = "MyAnalyzer"; diff --git a/tests/Test/Server/ExpirationConfigurationTest.php b/tests/Test/Server/ExpirationConfigurationTest.php index 7b7e158f..ed4b760d 100644 --- a/tests/Test/Server/ExpirationConfigurationTest.php +++ b/tests/Test/Server/ExpirationConfigurationTest.php @@ -5,12 +5,15 @@ use RavenDB\Documents\Operations\Expiration\ConfigureExpirationOperation; use RavenDB\Documents\Operations\Expiration\ConfigureExpirationOperationResult; use RavenDB\Documents\Operations\Expiration\ExpirationConfiguration; +use tests\RavenDB\Infrastructure\TestRunGuard; use tests\RavenDB\RemoteTestBase; class ExpirationConfigurationTest extends RemoteTestBase { public function testCanSetupExpiration(): void { + TestRunGuard::disableTestIfLicenseNotAvailableForV6($this); + $store = $this->getDocumentStore(); try { $expirationConfiguration = new ExpirationConfiguration(); From 2bb922a7e68bb3ecdf64fd07152e0c2f8d04ac1c Mon Sep 17 00:00:00 2001 From: Aleksandar Sabo Date: Tue, 28 Jan 2025 18:04:15 +0100 Subject: [PATCH 6/7] Switch test --- tests/Test/Issues/RavenDB_11440Test.php | 2 -- tests/Test/Server/LogsConfigurationTest.php | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Test/Issues/RavenDB_11440Test.php b/tests/Test/Issues/RavenDB_11440Test.php index 31e1a091..d2575dfc 100644 --- a/tests/Test/Issues/RavenDB_11440Test.php +++ b/tests/Test/Issues/RavenDB_11440Test.php @@ -16,8 +16,6 @@ class RavenDB_11440Test extends RemoteTestBase { public function testCanGetLogsConfigurationAndChangeMode(): void { - TestRunGuard::disableTestForRaven7AndLater($this); - $store = $this->getDocumentStore(); try { /** @var GetLogsConfigurationResult $configuration */ diff --git a/tests/Test/Server/LogsConfigurationTest.php b/tests/Test/Server/LogsConfigurationTest.php index 04e91507..529a4adf 100644 --- a/tests/Test/Server/LogsConfigurationTest.php +++ b/tests/Test/Server/LogsConfigurationTest.php @@ -14,6 +14,8 @@ class LogsConfigurationTest extends RemoteTestBase { public function testCanGetAndSetLogging(): void { + TestRunGuard::disableTestForRaven7AndLater($this); + $store = $this->getDocumentStore(); try { try { From 30c139c45578051c6ccaae3f2f2a72ca06e7b0b1 Mon Sep 17 00:00:00 2001 From: Aleksandar Sabo Date: Tue, 28 Jan 2025 18:16:02 +0100 Subject: [PATCH 7/7] Disable test for v7 --- tests/Test/Issues/RavenDB_11440Test.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/Test/Issues/RavenDB_11440Test.php b/tests/Test/Issues/RavenDB_11440Test.php index d2575dfc..31e1a091 100644 --- a/tests/Test/Issues/RavenDB_11440Test.php +++ b/tests/Test/Issues/RavenDB_11440Test.php @@ -16,6 +16,8 @@ class RavenDB_11440Test extends RemoteTestBase { public function testCanGetLogsConfigurationAndChangeMode(): void { + TestRunGuard::disableTestForRaven7AndLater($this); + $store = $this->getDocumentStore(); try { /** @var GetLogsConfigurationResult $configuration */