Skip to content

Add 7.0 to GHA RavenDB version matrix #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/RavenClient.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ on:
schedule:
- cron: "0 10 * * 6"
push:
branches: [ v5.4 ]
branches: [ v5.4, v6.0 ]
pull_request:
branches: [ v5.4 ]
branches: [ v5.4, v6.0 ]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
php-versions: [ "8.2", "8.3"]
serverVersion: [ "5.4" ]
php-versions: [ "8.2", "8.3", "8.4"]
serverVersion: [ "5.4", "6.2", "7.0" ]
fail-fast: false

env:
Expand Down
75 changes: 74 additions & 1 deletion tests/Infrastructure/TestRunGuard.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -17,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()) {
Expand All @@ -26,7 +45,61 @@ 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 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();
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);
}

}
2 changes: 1 addition & 1 deletion tests/Test/Client/HttpsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
5 changes: 5 additions & 0 deletions tests/Test/Client/Issues/RavenDB903Test/RavenDB903Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -535,6 +538,8 @@ public function testCanMakeDynamicDocumentQueries(): void

public function testCanMakeDynamicDocumentQueriesWithComplexProperties(): void
{
TestRunGuard::disableTestForRaven6AndLater($this);

$store = $this->getDocumentStore();
try {
(new ComplexDataIndex())->execute($store);
Expand Down
23 changes: 23 additions & 0 deletions tests/Test/Client/RevisionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class RevisionsTest extends RemoteTestBase
{
public function testRevisions(): void
{
TestRunGuard::disableTestIfLicenseNotAvailableForV6($this);

$store = $this->getDocumentStore();
try {
$this->setupRevisions($store, false, 4);
Expand Down Expand Up @@ -92,6 +94,7 @@ public function testRevisions(): void
public function testCanListRevisionsBin(): void
{
TestRunGuard::disableTestForRaven52($this);
TestRunGuard::disableTestForRaven6AndLater($this);

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

public function testCanGetRevisionsByChangeVectors(): void
{
TestRunGuard::disableTestIfLicenseNotAvailableForV6($this);

$store = $this->getDocumentStore();
try {
$id = "users/1";
Expand Down Expand Up @@ -330,6 +335,8 @@ public function testCanGetNonExistingRevisionsByChangeVectorAsyncLazily(): void

public function testCanGetRevisionsByChangeVectorsLazily(): void
{
TestRunGuard::disableTestIfLicenseNotAvailableForV6($this);

$store = $this->getDocumentStore();
try {
$id = "users/1";
Expand Down Expand Up @@ -387,6 +394,8 @@ public function testCanGetRevisionsByChangeVectorsLazily(): void

public function testCanGetForLazily(): void
{
TestRunGuard::disableTestIfLicenseNotAvailableForV6($this);

$store = $this->getDocumentStore();
try {
$id = "users/1";
Expand Down Expand Up @@ -457,6 +466,8 @@ public function testCanGetForLazily(): void

public function testCanGetRevisionsByIdAndTimeLazily(): void
{
TestRunGuard::disableTestIfLicenseNotAvailableForV6($this);

$store = $this->getDocumentStore();
try {
$id = "users/1";
Expand Down Expand Up @@ -510,6 +521,8 @@ public function testCanGetRevisionsByIdAndTimeLazily(): void

public function testCanGetMetadataForLazily(): void
{
TestRunGuard::disableTestIfLicenseNotAvailableForV6($this);

$store = $this->getDocumentStore();
try {
$id = "users/1";
Expand Down Expand Up @@ -571,6 +584,8 @@ public function testCanGetMetadataForLazily(): void

public function testCanGetRevisionsByChangeVectorLazily(): void
{
TestRunGuard::disableTestIfLicenseNotAvailableForV6($this);

$store = $this->getDocumentStore();
try {

Expand Down Expand Up @@ -646,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();
Expand Down Expand Up @@ -684,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);
Expand Down Expand Up @@ -749,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);
Expand Down Expand Up @@ -793,6 +814,8 @@ public function testCanGetRevisionsWithPaging2_UsingStoreOperation(): void

public function testCanGetRevisionsCountFor(): void
{
TestRunGuard::disableTestIfLicenseNotAvailableForV6($this);

$company = new Company();
$company->setName("Company Name");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -50,6 +53,8 @@ public function testLineStringsShouldIntersect(): void

public function testCirclesShouldNotIntersect(): void
{
TestRunGuard::disableTestForRaven6AndLater($this);

$store = $this->getDocumentStore();
try {
$store->executeIndex(new GeoIndex());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions tests/Test/Client/_QueryTest/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -764,6 +765,8 @@ public function testParametersInRawQuery(): void

public function testQueryLucene(): void
{
TestRunGuard::disableTestForRaven6AndLater($this);

$store = $this->getDocumentStore();
try {
$this->addUsers($store);
Expand Down Expand Up @@ -1031,6 +1034,8 @@ public function testQueryWhereExists(): void

public function testQueryWithBoost(): void
{
TestRunGuard::disableTestForRaven6AndLater($this);

$store = $this->getDocumentStore();
try {
$this->addUsers($store);
Expand Down
Loading