Skip to content

Commit 9e0b8b6

Browse files
authored
Add 7.0 to GHA RavenDB version matrix (#70)
* Add PHP 8.4 to test matrix * Add Raven 7.0 to test matrix * Disable failing tests for RDB v6 * Disable tests in v7 that require license if license is not provided
1 parent 0f0ebe7 commit 9e0b8b6

File tree

25 files changed

+183
-7
lines changed

25 files changed

+183
-7
lines changed

.github/workflows/RavenClient.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ on:
33
schedule:
44
- cron: "0 10 * * 6"
55
push:
6-
branches: [ v5.4 ]
6+
branches: [ v5.4, v6.0 ]
77
pull_request:
8-
branches: [ v5.4 ]
8+
branches: [ v5.4, v6.0 ]
99

1010
jobs:
1111
build:
1212
runs-on: ubuntu-latest
1313

1414
strategy:
1515
matrix:
16-
php-versions: [ "8.2", "8.3"]
17-
serverVersion: [ "5.4" ]
16+
php-versions: [ "8.2", "8.3", "8.4"]
17+
serverVersion: [ "5.4", "6.2", "7.0" ]
1818
fail-fast: false
1919

2020
env:

tests/Infrastructure/TestRunGuard.php

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@
33
namespace tests\RavenDB\Infrastructure;
44

55
use PHPUnit\Framework\TestCase;
6+
use PHPUnit\Framework\Warning;
67

78
class TestRunGuard
89
{
910
public static string $ENV_RAVEN_LICENSE = "RAVEN_LICENSE";
1011
public static string $SERVER_VERSION = "SERVER_VERSION";
1112

13+
public static int $MAJOR_VERSION = 0;
14+
public static int $MINOR_VERSION = 1;
15+
1216
public static function disableTestIfLicenseNotAvailable(TestCase $testCase): void
1317
{
1418
$ravenLicense = getenv(self::$ENV_RAVEN_LICENSE);
@@ -17,6 +21,21 @@ public static function disableTestIfLicenseNotAvailable(TestCase $testCase): voi
1721
}
1822
}
1923

24+
public static function disableTestIfLicenseNotAvailableForV6(TestCase $testCase): void
25+
{
26+
$ravenLicense = getenv(self::$ENV_RAVEN_LICENSE);
27+
if (!empty($ravenLicense)) {
28+
return;
29+
}
30+
31+
$version = self::getServerVersion();
32+
if ($version[self::$MAJOR_VERSION] < 6) {
33+
return;
34+
}
35+
36+
$testCase->markTestSkipped("Test disabled on Pull Request. License not available.");
37+
}
38+
2039
public static function disableTestForRaven52(TestCase $testCase): void
2140
{
2241
if (self::isServerVersion52()) {
@@ -26,7 +45,61 @@ public static function disableTestForRaven52(TestCase $testCase): void
2645

2746
public static function isServerVersion52(): bool
2847
{
48+
$versionString = self::getServerVersionAsString();
49+
50+
return $versionString == '5.2';
51+
}
52+
53+
public static function disableTestForRaven6AndLater(TestCase $testCase): void
54+
{
55+
if (self::isServerVersionGreaterOrEqualThan60()) {
56+
$testCase->markTestSkipped("Test disabled for RavenDB version greater than 6.0");
57+
}
58+
}
59+
60+
public static function isServerVersionGreaterOrEqualThan70(): bool
61+
{
62+
$version = self::getServerVersion();
63+
return intval($version[self::$MAJOR_VERSION]) >= 7;
64+
}
65+
66+
public static function disableTestForRaven7AndLater(TestCase $testCase): void
67+
{
68+
if (self::isServerVersionGreaterOrEqualThan70()) {
69+
$testCase->markTestSkipped("Test disabled for RavenDB version greater than 7.0");
70+
}
71+
}
72+
73+
public static function isServerVersionGreaterOrEqualThan60(): bool
74+
{
75+
$version = self::getServerVersion();
76+
return intval($version[self::$MAJOR_VERSION]) >= 6;
77+
}
78+
79+
public static function getServerVersionAsString(): string
80+
{
81+
// Server version saved in .env variable in a format: MAJOR.MINOR, for example: "5.4"
2982
$serverVersion = getenv(self::$SERVER_VERSION);
30-
return $serverVersion == '5.2';
83+
84+
if (!$serverVersion) {
85+
return throw new Warning('RavenDB SERVER_VERSION is not set in .env variables');
86+
}
87+
88+
return $serverVersion;
89+
}
90+
91+
/**
92+
* Version information in array
93+
* - $version[0] - major version
94+
* - $version[1] - minor version
95+
*
96+
* @return array with information about major and minor version
97+
*/
98+
public static function getServerVersion(): array
99+
{
100+
$versionString = self::getServerVersionAsString();
101+
102+
return explode('.', $versionString);
31103
}
104+
32105
}

tests/Test/Client/HttpsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ public function testShouldThrowAuthorizationExceptionWhenNotAuthorized() {
232232
$session = $storeWithOutCert->openSession();
233233
try {
234234
$this->expectException(AuthorizationException::class);
235-
$this->expectErrorMessage('Forbidden access to ');
235+
$this->expectExceptionMessage('Forbidden access to ');
236236

237237
$user1 = $session->load(User::class, "users/1");
238238

tests/Test/Client/Issues/RavenDB903Test/RavenDB903Test.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use RavenDB\Documents\Session\DocumentQueryInterface;
66
use RavenDB\Documents\Session\DocumentSessionInterface;
7+
use tests\RavenDB\Infrastructure\TestRunGuard;
78
use tests\RavenDB\RemoteTestBase;
89
use tests\RavenDB\Test\Client\Issues\RavenDB903Test\Entity\Product;
910
use tests\RavenDB\Test\Client\Issues\RavenDB903Test\Entity\TestIndex;
@@ -12,6 +13,8 @@ class RavenDB903Test extends RemoteTestBase
1213
{
1314
public function test1(): void
1415
{
16+
TestRunGuard::disableTestForRaven6AndLater($this);
17+
1518
$this->doTest(
1619
function (DocumentSessionInterface $session): DocumentQueryInterface {
1720
return $session->advanced()->documentQuery(Product::class, TestIndex::class)
@@ -24,6 +27,8 @@ function (DocumentSessionInterface $session): DocumentQueryInterface {
2427

2528
public function test2(): void
2629
{
30+
TestRunGuard::disableTestForRaven6AndLater($this);
31+
2732
$this->doTest(
2833
function (DocumentSessionInterface $session): DocumentQueryInterface {
2934
return $session->advanced()->documentQuery(Product::class, TestIndex::class)

tests/Test/Client/MoreLikeThis/_MoreLikeThisTest/MoreLikeThisTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use RavenDB\Documents\DocumentStoreInterface;
66
use RavenDB\Documents\Queries\MoreLikeThis\MoreLikeThisOptions;
77
use RavenDB\Documents\Queries\MoreLikeThis\MoreLikeThisStopWords;
8+
use tests\RavenDB\Infrastructure\TestRunGuard;
89
use tests\RavenDB\RemoteTestBase;
910

1011
class MoreLikeThisTest extends RemoteTestBase
@@ -384,6 +385,8 @@ public function test_can_Use_Min_Doc_Freq_Param(): void
384385

385386
public function test_can_Use_Boost_Param(): void
386387
{
388+
TestRunGuard::disableTestForRaven6AndLater($this);
389+
387390
$store = $this->getDocumentStore();
388391
try {
389392
$key = "data/1-A";
@@ -535,6 +538,8 @@ public function testCanMakeDynamicDocumentQueries(): void
535538

536539
public function testCanMakeDynamicDocumentQueriesWithComplexProperties(): void
537540
{
541+
TestRunGuard::disableTestForRaven6AndLater($this);
542+
538543
$store = $this->getDocumentStore();
539544
try {
540545
(new ComplexDataIndex())->execute($store);

tests/Test/Client/RevisionsTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ class RevisionsTest extends RemoteTestBase
2525
{
2626
public function testRevisions(): void
2727
{
28+
TestRunGuard::disableTestIfLicenseNotAvailableForV6($this);
29+
2830
$store = $this->getDocumentStore();
2931
try {
3032
$this->setupRevisions($store, false, 4);
@@ -92,6 +94,7 @@ public function testRevisions(): void
9294
public function testCanListRevisionsBin(): void
9395
{
9496
TestRunGuard::disableTestForRaven52($this);
97+
TestRunGuard::disableTestForRaven6AndLater($this);
9598

9699
$store = $this->getDocumentStore();
97100
try {
@@ -129,6 +132,8 @@ public function testCanListRevisionsBin(): void
129132

130133
public function testCanGetRevisionsByChangeVectors(): void
131134
{
135+
TestRunGuard::disableTestIfLicenseNotAvailableForV6($this);
136+
132137
$store = $this->getDocumentStore();
133138
try {
134139
$id = "users/1";
@@ -330,6 +335,8 @@ public function testCanGetNonExistingRevisionsByChangeVectorAsyncLazily(): void
330335

331336
public function testCanGetRevisionsByChangeVectorsLazily(): void
332337
{
338+
TestRunGuard::disableTestIfLicenseNotAvailableForV6($this);
339+
333340
$store = $this->getDocumentStore();
334341
try {
335342
$id = "users/1";
@@ -387,6 +394,8 @@ public function testCanGetRevisionsByChangeVectorsLazily(): void
387394

388395
public function testCanGetForLazily(): void
389396
{
397+
TestRunGuard::disableTestIfLicenseNotAvailableForV6($this);
398+
390399
$store = $this->getDocumentStore();
391400
try {
392401
$id = "users/1";
@@ -457,6 +466,8 @@ public function testCanGetForLazily(): void
457466

458467
public function testCanGetRevisionsByIdAndTimeLazily(): void
459468
{
469+
TestRunGuard::disableTestIfLicenseNotAvailableForV6($this);
470+
460471
$store = $this->getDocumentStore();
461472
try {
462473
$id = "users/1";
@@ -510,6 +521,8 @@ public function testCanGetRevisionsByIdAndTimeLazily(): void
510521

511522
public function testCanGetMetadataForLazily(): void
512523
{
524+
TestRunGuard::disableTestIfLicenseNotAvailableForV6($this);
525+
513526
$store = $this->getDocumentStore();
514527
try {
515528
$id = "users/1";
@@ -571,6 +584,8 @@ public function testCanGetMetadataForLazily(): void
571584

572585
public function testCanGetRevisionsByChangeVectorLazily(): void
573586
{
587+
TestRunGuard::disableTestIfLicenseNotAvailableForV6($this);
588+
574589
$store = $this->getDocumentStore();
575590
try {
576591

@@ -646,6 +661,8 @@ public function testCanGetRevisionsByChangeVectorLazily(): void
646661

647662
public function testCanGetAllRevisionsForDocument_UsingStoreOperation(): void
648663
{
664+
TestRunGuard::disableTestIfLicenseNotAvailableForV6($this);
665+
649666
$company = new Company();
650667
$company->setName("Company Name");
651668
$store = $this->getDocumentStore();
@@ -684,6 +701,8 @@ public function testCanGetAllRevisionsForDocument_UsingStoreOperation(): void
684701

685702
public function testCanGetRevisionsWithPaging_UsingStoreOperation(): void
686703
{
704+
TestRunGuard::disableTestIfLicenseNotAvailableForV6($this);
705+
687706
$store = $this->getDocumentStore();
688707
try {
689708
$this->setupRevisions($store, false, 123);
@@ -749,6 +768,8 @@ public function testCanGetRevisionsWithPaging_UsingStoreOperation(): void
749768

750769
public function testCanGetRevisionsWithPaging2_UsingStoreOperation(): void
751770
{
771+
TestRunGuard::disableTestIfLicenseNotAvailableForV6($this);
772+
752773
$store = $this->getDocumentStore();
753774
try {
754775
$this->setupRevisions($store, false, 100);
@@ -793,6 +814,8 @@ public function testCanGetRevisionsWithPaging2_UsingStoreOperation(): void
793814

794815
public function testCanGetRevisionsCountFor(): void
795816
{
817+
TestRunGuard::disableTestIfLicenseNotAvailableForV6($this);
818+
796819
$company = new Company();
797820
$company->setName("Company Name");
798821

tests/Test/Client/Spatial/_BoundingBoxIndexTest/BoundingBoxIndexTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22

33
namespace tests\RavenDB\Test\Client\Spatial\_BoundingBoxIndexTest;
44

5+
use tests\RavenDB\Infrastructure\TestRunGuard;
56
use tests\RavenDB\RemoteTestBase;
67

78
class BoundingBoxIndexTest extends RemoteTestBase
89
{
910
public function testBoundingBoxTest(): void
1011
{
12+
TestRunGuard::disableTestForRaven6AndLater($this);
13+
1114
$polygon = "POLYGON ((0 0, 0 5, 1 5, 1 1, 5 1, 5 5, 6 5, 6 0, 0 0))";
1215
$rectangle1 = "2 2 4 4";
1316
$rectangle2 = "6 6 10 10";

tests/Test/Client/Spatial/_SimonBartlettTest/SimonBartlettTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
namespace tests\RavenDB\Test\Client\Spatial\_SimonBartlettTest;
44

55
use RavenDB\Documents\Indexes\Spatial\SpatialRelation;
6+
use tests\RavenDB\Infrastructure\TestRunGuard;
67
use tests\RavenDB\RemoteTestBase;
78

89
class SimonBartlettTest extends RemoteTestBase
910
{
1011
public function testLineStringsShouldIntersect(): void
1112
{
13+
TestRunGuard::disableTestForRaven6AndLater($this);
14+
1215
$store = $this->getDocumentStore();
1316
try {
1417
$store->executeIndex(new GeoIndex());
@@ -50,6 +53,8 @@ public function testLineStringsShouldIntersect(): void
5053

5154
public function testCirclesShouldNotIntersect(): void
5255
{
56+
TestRunGuard::disableTestForRaven6AndLater($this);
57+
5358
$store = $this->getDocumentStore();
5459
try {
5560
$store->executeIndex(new GeoIndex());

tests/Test/Client/Spatial/_SpatialSearchTest/SpatialSearchTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use RavenDB\Documents\Queries\Query;
77
use RavenDB\Documents\Session\QueryStatistics;
88
use RavenDB\Utils\DateUtils;
9+
use tests\RavenDB\Infrastructure\TestRunGuard;
910
use tests\RavenDB\RemoteTestBase;
1011

1112
class SpatialSearchTest extends RemoteTestBase
@@ -78,6 +79,8 @@ public function test_can_do_spatial_search_with_client_api3(): void
7879

7980
public function test_can_do_spatial_search_with_client_api_within_given_capacity(): void
8081
{
82+
TestRunGuard::disableTestForRaven6AndLater($this);
83+
8184
$store = $this->getDocumentStore();
8285
try {
8386
(new SpatialIdx())->execute($store);

tests/Test/Client/_QueryTest/QueryTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use RavenDB\Utils\StringUtils;
2121
use tests\RavenDB\Infrastructure\Entity\User;
2222
use tests\RavenDB\Infrastructure\Entity\Order;
23+
use tests\RavenDB\Infrastructure\TestRunGuard;
2324
use tests\RavenDB\RemoteTestBase;
2425
use tests\RavenDB\Test\Client\_QueryTest\Entity\Article;
2526
use tests\RavenDB\Test\Client\_QueryTest\Entity\Dog;
@@ -764,6 +765,8 @@ public function testParametersInRawQuery(): void
764765

765766
public function testQueryLucene(): void
766767
{
768+
TestRunGuard::disableTestForRaven6AndLater($this);
769+
767770
$store = $this->getDocumentStore();
768771
try {
769772
$this->addUsers($store);
@@ -1031,6 +1034,8 @@ public function testQueryWhereExists(): void
10311034

10321035
public function testQueryWithBoost(): void
10331036
{
1037+
TestRunGuard::disableTestForRaven6AndLater($this);
1038+
10341039
$store = $this->getDocumentStore();
10351040
try {
10361041
$this->addUsers($store);

0 commit comments

Comments
 (0)