Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public static function provideInvalidPHPValuesForDatabaseTransformation(): array
];
}

#[DataProvider('provideInvalidDatabaseValuesForPHPTransformationForPHPTransformation')]
#[DataProvider('provideInvalidDatabaseValuesForPHPTransformation')]
#[Test]
public function throws_exception_when_invalid_data_provided_to_convert_to_php_value(string $postgresValue): void
{
Expand All @@ -114,7 +114,7 @@ public function throws_exception_when_invalid_data_provided_to_convert_to_php_va
/**
* @return array<string, array{string}>
*/
public static function provideInvalidDatabaseValuesForPHPTransformationForPHPTransformation(): array
public static function provideInvalidDatabaseValuesForPHPTransformation(): array
{
return [
'invalid format' => ['{"invalid-cidr"}'],
Expand Down
24 changes: 12 additions & 12 deletions tests/Unit/MartinGeorgiev/Doctrine/DBAL/Types/MacaddrTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,57 +36,57 @@ public function has_name(): void

#[DataProvider('provideValidTransformations')]
#[Test]
public function can_transform_from_php_value(?string $phpInput, ?string $postgresValueAfterNormalisation, ?string $phpValueAfterRetrievalFromDatabase): void
public function can_transform_from_php_value(?string $phpInput, ?string $postgresValueAfterNormalization, ?string $phpValueAfterRetrievalFromDatabase): void
{
self::assertEquals($postgresValueAfterNormalisation, $this->fixture->convertToDatabaseValue($phpInput, $this->platform));
self::assertEquals($postgresValueAfterNormalization, $this->fixture->convertToDatabaseValue($phpInput, $this->platform));
}

#[DataProvider('provideValidTransformations')]
#[Test]
public function can_transform_to_php_value(?string $phpInput, ?string $postgresValueAfterNormalisation, ?string $phpValueAfterRetrievalFromDatabase): void
public function can_transform_to_php_value(?string $phpInput, ?string $postgresValueAfterNormalization, ?string $phpValueAfterRetrievalFromDatabase): void
{
self::assertEquals($phpValueAfterRetrievalFromDatabase, $this->fixture->convertToPHPValue($postgresValueAfterNormalisation, $this->platform));
self::assertEquals($phpValueAfterRetrievalFromDatabase, $this->fixture->convertToPHPValue($postgresValueAfterNormalization, $this->platform));
}

/**
* @return array<string, array{phpInput: string|null, postgresValueAfterNormalisation: string|null, postgresValueAfterNormalisation: string|null}>
* @return array<string, array{phpInput: string|null, postgresValueAfterNormalization: string|null, phpValueAfterRetrievalFromDatabase: string|null}>
*/
public static function provideValidTransformations(): array
{
return [
'null' => [
'phpInput' => null,
'postgresValueAfterNormalisation' => null,
'postgresValueAfterNormalization' => null,
'phpValueAfterRetrievalFromDatabase' => null,
],
'colon-separated lowercase' => [
'phpInput' => '08:00:2b:01:02:03',
'postgresValueAfterNormalisation' => '08:00:2b:01:02:03',
'postgresValueAfterNormalization' => '08:00:2b:01:02:03',
'phpValueAfterRetrievalFromDatabase' => '08:00:2b:01:02:03',
],
'colon-separated uppercase' => [
'phpInput' => '08:00:2B:01:02:03',
'postgresValueAfterNormalisation' => '08:00:2b:01:02:03',
'postgresValueAfterNormalization' => '08:00:2b:01:02:03',
'phpValueAfterRetrievalFromDatabase' => '08:00:2b:01:02:03',
],
'hyphen-separated lowercase' => [
'phpInput' => '08-00-2b-01-02-03',
'postgresValueAfterNormalisation' => '08:00:2b:01:02:03',
'postgresValueAfterNormalization' => '08:00:2b:01:02:03',
'phpValueAfterRetrievalFromDatabase' => '08:00:2b:01:02:03',
],
'hyphen-separated uppercase' => [
'phpInput' => '08-00-2B-01-02-03',
'postgresValueAfterNormalisation' => '08:00:2b:01:02:03',
'postgresValueAfterNormalization' => '08:00:2b:01:02:03',
'phpValueAfterRetrievalFromDatabase' => '08:00:2b:01:02:03',
],
'no separator' => [
'phpInput' => '08002B010203',
'postgresValueAfterNormalisation' => '08:00:2b:01:02:03',
'postgresValueAfterNormalization' => '08:00:2b:01:02:03',
'phpValueAfterRetrievalFromDatabase' => '08:00:2b:01:02:03',
],
'mixed case no separator' => [
'phpInput' => '08002b010203',
'postgresValueAfterNormalisation' => '08:00:2b:01:02:03',
'postgresValueAfterNormalization' => '08:00:2b:01:02:03',
'phpValueAfterRetrievalFromDatabase' => '08:00:2b:01:02:03',
],
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\ArrayPosition;
use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\BaseVariadicFunction;
use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\Exception\InvalidArgumentForVariadicFunctionException;
use PHPUnit\Framework\Attributes\Test;

class ArrayPositionTest extends BaseVariadicFunctionTestCase
{
Expand Down Expand Up @@ -43,7 +44,8 @@ protected function getDqlStatements(): array
];
}

public function test_too_few_arguments_throws_exception(): void
#[Test]
public function too_few_arguments_throws_exception(): void
{
$this->expectException(InvalidArgumentForVariadicFunctionException::class);
$this->expectExceptionMessage('array_position() requires at least 2 arguments');
Expand All @@ -52,7 +54,8 @@ public function test_too_few_arguments_throws_exception(): void
$this->buildEntityManager()->createQuery($dql)->getSQL();
}

public function test_too_many_arguments_throws_exception(): void
#[Test]
public function too_many_arguments_throws_exception(): void
{
$this->expectException(InvalidArgumentForVariadicFunctionException::class);
$this->expectExceptionMessage('array_position() requires between 2 and 3 arguments');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\BaseVariadicFunction;
use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\Exception\InvalidArgumentForVariadicFunctionException;
use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\Exception\InvalidBooleanException;
use PHPUnit\Framework\Attributes\Test;

class ArrayToJsonTest extends BaseVariadicFunctionTestCase
{
Expand Down Expand Up @@ -40,7 +41,8 @@ protected function getDqlStatements(): array
];
}

public function test_invalid_boolean_throws_exception(): void
#[Test]
public function invalid_boolean_throws_exception(): void
{
$this->expectException(InvalidBooleanException::class);
$this->expectExceptionMessage('Invalid boolean value "invalid" provided for array_to_json. Must be "true" or "false".');
Expand All @@ -49,7 +51,8 @@ public function test_invalid_boolean_throws_exception(): void
$this->buildEntityManager()->createQuery($dql)->getSQL();
}

public function test_too_many_arguments_throws_exception(): void
#[Test]
public function too_many_arguments_throws_exception(): void
{
$this->expectException(InvalidArgumentForVariadicFunctionException::class);
$this->expectExceptionMessage('array_to_json() requires between 1 and 2 arguments');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\DateAdd;
use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\Exception\InvalidArgumentForVariadicFunctionException;
use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\Exception\InvalidTimezoneException;
use PHPUnit\Framework\Attributes\Test;

class DateAddTest extends BaseVariadicFunctionTestCase
{
Expand Down Expand Up @@ -44,7 +45,8 @@ protected function getDqlStatements(): array
];
}

public function test_invalid_timezone_throws_exception(): void
#[Test]
public function invalid_timezone_throws_exception(): void
{
$this->expectException(InvalidTimezoneException::class);
$this->expectExceptionMessage('Invalid timezone "Invalid/Timezone" provided for date_add');
Expand All @@ -53,7 +55,8 @@ public function test_invalid_timezone_throws_exception(): void
$this->buildEntityManager()->createQuery($dql)->getSQL();
}

public function test_too_few_arguments_throws_exception(): void
#[Test]
public function too_few_arguments_throws_exception(): void
{
$this->expectException(InvalidArgumentForVariadicFunctionException::class);
$this->expectExceptionMessage('date_add() requires at least 2 arguments');
Expand All @@ -62,7 +65,8 @@ public function test_too_few_arguments_throws_exception(): void
$this->buildEntityManager()->createQuery($dql)->getSQL();
}

public function test_too_many_arguments_throws_exception(): void
#[Test]
public function too_many_arguments_throws_exception(): void
{
$this->expectException(InvalidArgumentForVariadicFunctionException::class);
$this->expectExceptionMessage('date_add() requires between 2 and 3 arguments');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\DateSubtract;
use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\Exception\InvalidArgumentForVariadicFunctionException;
use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\Exception\InvalidTimezoneException;
use PHPUnit\Framework\Attributes\Test;

class DateSubtractTest extends BaseVariadicFunctionTestCase
{
Expand Down Expand Up @@ -42,7 +43,8 @@ protected function getDqlStatements(): array
];
}

public function test_invalid_timezone_throws_exception(): void
#[Test]
public function invalid_timezone_throws_exception(): void
{
$this->expectException(InvalidTimezoneException::class);
$this->expectExceptionMessage('Invalid timezone "Invalid/Timezone" provided for date_subtract');
Expand All @@ -51,7 +53,8 @@ public function test_invalid_timezone_throws_exception(): void
$this->buildEntityManager()->createQuery($dql)->getSQL();
}

public function test_too_few_arguments_throws_exception(): void
#[Test]
public function too_few_arguments_throws_exception(): void
{
$this->expectException(InvalidArgumentForVariadicFunctionException::class);
$this->expectExceptionMessage('date_subtract() requires at least 2 arguments');
Expand All @@ -60,7 +63,8 @@ public function test_too_few_arguments_throws_exception(): void
$this->buildEntityManager()->createQuery($dql)->getSQL();
}

public function test_too_many_arguments_throws_exception(): void
#[Test]
public function too_many_arguments_throws_exception(): void
{
$this->expectException(InvalidArgumentForVariadicFunctionException::class);
$this->expectExceptionMessage('date_subtract() requires between 2 and 3 arguments');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\Exception\InvalidArgumentForVariadicFunctionException;
use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\Exception\InvalidBooleanException;
use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\JsonbInsert;
use PHPUnit\Framework\Attributes\Test;

class JsonbInsertTest extends TestCase
{
Expand All @@ -34,7 +35,8 @@ protected function getDqlStatements(): array
];
}

public function test_invalid_boolean_throws_exception(): void
#[Test]
public function invalid_boolean_throws_exception(): void
{
$this->expectException(InvalidBooleanException::class);
$this->expectExceptionMessage('Invalid boolean value "invalid" provided for jsonb_insert. Must be "true" or "false".');
Expand All @@ -43,7 +45,8 @@ public function test_invalid_boolean_throws_exception(): void
$this->buildEntityManager()->createQuery($dql)->getSQL();
}

public function test_too_few_arguments_throws_exception(): void
#[Test]
public function too_few_arguments_throws_exception(): void
{
$this->expectException(InvalidArgumentForVariadicFunctionException::class);
$this->expectExceptionMessage('jsonb_insert() requires at least 3 arguments');
Expand All @@ -52,7 +55,8 @@ public function test_too_few_arguments_throws_exception(): void
$this->buildEntityManager()->createQuery($dql)->getSQL();
}

public function test_too_many_arguments_throws_exception(): void
#[Test]
public function too_many_arguments_throws_exception(): void
{
$this->expectException(InvalidArgumentForVariadicFunctionException::class);
$this->expectExceptionMessage('jsonb_insert() requires between 3 and 4 arguments');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\Exception\InvalidArgumentForVariadicFunctionException;
use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\Exception\InvalidBooleanException;
use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\JsonbPathExists;
use PHPUnit\Framework\Attributes\Test;

class JsonbPathExistsTest extends BaseVariadicFunctionTestCase
{
Expand Down Expand Up @@ -44,7 +45,8 @@ protected function getDqlStatements(): array
];
}

public function test_invalid_boolean_throws_exception(): void
#[Test]
public function invalid_boolean_throws_exception(): void
{
$this->expectException(InvalidBooleanException::class);
$this->expectExceptionMessage('Invalid boolean value "invalid" provided for jsonb_path_exists. Must be "true" or "false".');
Expand All @@ -53,7 +55,8 @@ public function test_invalid_boolean_throws_exception(): void
$this->buildEntityManager()->createQuery($dql)->getSQL();
}

public function test_too_few_arguments_throws_exception(): void
#[Test]
public function too_few_arguments_throws_exception(): void
{
$this->expectException(InvalidArgumentForVariadicFunctionException::class);
$this->expectExceptionMessage('jsonb_path_exists() requires at least 2 arguments');
Expand All @@ -62,7 +65,8 @@ public function test_too_few_arguments_throws_exception(): void
$this->buildEntityManager()->createQuery($dql)->getSQL();
}

public function test_too_many_arguments_throws_exception(): void
#[Test]
public function too_many_arguments_throws_exception(): void
{
$this->expectException(InvalidArgumentForVariadicFunctionException::class);
$this->expectExceptionMessage('jsonb_path_exists() requires between 2 and 4 arguments');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\Exception\InvalidArgumentForVariadicFunctionException;
use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\Exception\InvalidBooleanException;
use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\JsonbPathMatch;
use PHPUnit\Framework\Attributes\Test;

class JsonbPathMatchTest extends BaseVariadicFunctionTestCase
{
Expand Down Expand Up @@ -44,7 +45,8 @@ protected function getDqlStatements(): array
];
}

public function test_invalid_boolean_throws_exception(): void
#[Test]
public function invalid_boolean_throws_exception(): void
{
$this->expectException(InvalidBooleanException::class);
$this->expectExceptionMessage('Invalid boolean value "invalid" provided for jsonb_path_match. Must be "true" or "false".');
Expand All @@ -53,7 +55,8 @@ public function test_invalid_boolean_throws_exception(): void
$this->buildEntityManager()->createQuery($dql)->getSQL();
}

public function test_too_few_arguments_throws_exception(): void
#[Test]
public function too_few_arguments_throws_exception(): void
{
$this->expectException(InvalidArgumentForVariadicFunctionException::class);
$this->expectExceptionMessage('jsonb_path_match() requires at least 2 arguments');
Expand All @@ -62,7 +65,8 @@ public function test_too_few_arguments_throws_exception(): void
$this->buildEntityManager()->createQuery($dql)->getSQL();
}

public function test_too_many_arguments_throws_exception(): void
#[Test]
public function too_many_arguments_throws_exception(): void
{
$this->expectException(InvalidArgumentForVariadicFunctionException::class);
$this->expectExceptionMessage('jsonb_path_match() requires between 2 and 4 arguments');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\Exception\InvalidArgumentForVariadicFunctionException;
use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\Exception\InvalidBooleanException;
use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\JsonbPathQueryArray;
use PHPUnit\Framework\Attributes\Test;

class JsonbPathQueryArrayTest extends BaseVariadicFunctionTestCase
{
Expand Down Expand Up @@ -44,7 +45,8 @@ protected function getDqlStatements(): array
];
}

public function test_invalid_boolean_throws_exception(): void
#[Test]
public function invalid_boolean_throws_exception(): void
{
$this->expectException(InvalidBooleanException::class);
$this->expectExceptionMessage('Invalid boolean value "invalid" provided for jsonb_path_query_array. Must be "true" or "false".');
Expand All @@ -53,7 +55,8 @@ public function test_invalid_boolean_throws_exception(): void
$this->buildEntityManager()->createQuery($dql)->getSQL();
}

public function test_too_few_arguments_throws_exception(): void
#[Test]
public function too_few_arguments_throws_exception(): void
{
$this->expectException(InvalidArgumentForVariadicFunctionException::class);
$this->expectExceptionMessage('jsonb_path_query_array() requires at least 2 arguments');
Expand All @@ -62,7 +65,8 @@ public function test_too_few_arguments_throws_exception(): void
$this->buildEntityManager()->createQuery($dql)->getSQL();
}

public function test_too_many_arguments_throws_exception(): void
#[Test]
public function too_many_arguments_throws_exception(): void
{
$this->expectException(InvalidArgumentForVariadicFunctionException::class);
$this->expectExceptionMessage('jsonb_path_query_array() requires between 2 and 4 arguments');
Expand Down
Loading
Loading