Skip to content

Commit c7896ca

Browse files
authored
Merge pull request #3 from yokai-php/php8
Switched minimum PHP version to 8.0
2 parents 53a2106 + 0ef665a commit c7896ca

File tree

4 files changed

+25
-42
lines changed

4 files changed

+25
-42
lines changed

.github/workflows/tests.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ jobs:
1414
strategy:
1515
matrix:
1616
include:
17-
- php-version: 7.4
17+
- php-version: 8.0
18+
- php-version: 8.2
1819

1920
steps:
2021
- name: "Checkout"
@@ -40,7 +41,7 @@ jobs:
4041
strategy:
4142
matrix:
4243
include:
43-
- php-version: 7.4
44+
- php-version: 8.2
4445

4546
steps:
4647
- name: "Checkout"
@@ -66,8 +67,7 @@ jobs:
6667
strategy:
6768
matrix:
6869
include:
69-
- php-version: 7.4
70-
symfony-version: 5.1.*
70+
- php-version: 8.2
7171

7272
steps:
7373
- name: "Checkout"
@@ -93,7 +93,7 @@ jobs:
9393
strategy:
9494
matrix:
9595
include:
96-
- php-version: 7.4
96+
- php-version: 8.2
9797

9898
steps:
9999
- name: "Checkout"

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
}
1111
],
1212
"require": {
13-
"php": "^7.4|^8.0",
13+
"php": "^8.0",
1414
"doctrine/orm": "^2.7",
1515
"webmozart/assert": "^1.9"
1616
},
@@ -22,7 +22,8 @@
2222
"require-dev": {
2323
"phpunit/phpunit": "^9.4",
2424
"phpstan/phpstan": "^0.12.76",
25-
"squizlabs/php_codesniffer": "^3.5"
25+
"squizlabs/php_codesniffer": "^3.5",
26+
"symfony/cache": "^5.4|^6.0"
2627
},
2728
"autoload-dev": {
2829
"psr-4": {

tests/EntityTest.php

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
namespace Yokai\DoctrineValueObject\Tests;
66

77
use DateTimeImmutable;
8+
use Doctrine\DBAL\DriverManager;
89
use Doctrine\DBAL\Types\Type;
910
use Doctrine\ORM\EntityManager;
11+
use Doctrine\ORM\ORMSetup;
1012
use Doctrine\ORM\Tools\SchemaTool;
11-
use Doctrine\ORM\Tools\Setup;
1213
use PHPUnit\Framework\TestCase;
1314
use Yokai\DoctrineValueObject\Doctrine\Types;
1415

@@ -34,10 +35,7 @@ public function testUserWithNoValues(): void
3435

3536
// fetch row from database
3637
$sql = "SELECT * FROM user WHERE id = ?";
37-
$stmt = $entityManager->getConnection()->prepare($sql);
38-
$stmt->bindValue(1, $user->id);
39-
$stmt->execute();
40-
$row = $stmt->fetchAssociative();
38+
$row = $entityManager->getConnection()->fetchAssociative($sql, [$user->id]);
4139
// assert all columns are null
4240
self::assertNull($row['status']);
4341
self::assertNull($row['birthdate']);
@@ -77,12 +75,9 @@ public function testUserWithAllValues(): void
7775

7876
// fetch row from database
7977
$sql = "SELECT * FROM user WHERE id = ?";
80-
$stmt = $entityManager->getConnection()->prepare($sql);
81-
$stmt->bindValue(1, $user->id);
82-
$stmt->execute();
83-
$row = $stmt->fetchAssociative();
78+
$row = $entityManager->getConnection()->fetchAssociative($sql, [$user->id]);
8479
// assert all columns are filled with value object values
85-
self::assertSame('0', $row['status']);
80+
self::assertSame('0', (string)$row['status']);
8681
self::assertSame('1986-11-17 00:00:00', $row['birthdate']);
8782
self::assertSame('+33677889900', $row['contactPhoneNumber']);
8883
self::assertSame('["+33455667788","+33233445566"]', $row['phoneNumbers']);
@@ -110,8 +105,9 @@ private function manager(): EntityManager
110105
(new Types(self::TYPES))->register(Type::getTypeRegistry());
111106

112107
// create entity manager with an sqlite in memory storage
113-
$config = Setup::createAnnotationMetadataConfiguration([__DIR__], true, null, null, false);
114-
$entityManager = EntityManager::create(['url' => 'sqlite:///:memory:'], $config);
108+
$config = ORMSetup::createAttributeMetadataConfiguration([__DIR__], true);
109+
$connection = DriverManager::getConnection(['url' => 'sqlite:///:memory:']);
110+
$entityManager = new EntityManager($connection, $config);
115111
// create schema
116112
(new SchemaTool($entityManager))
117113
->createSchema($entityManager->getMetadataFactory()->getAllMetadata());

tests/User.php

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,26 @@
66

77
use Doctrine\ORM\Mapping as ORM;
88

9-
/**
10-
* @ORM\Entity()
11-
*/
9+
#[ORM\Entity]
1210
final class User
1311
{
14-
/**
15-
* @ORM\Id()
16-
* @ORM\GeneratedValue()
17-
* @ORM\Column(type="integer")
18-
*/
12+
#[ORM\Id]
13+
#[ORM\GeneratedValue]
14+
#[ORM\Column(type: "integer")]
1915
public ?int $id = null;
2016

21-
/**
22-
* @ORM\Column(type="user_status", nullable=true)
23-
*/
17+
#[ORM\Column(type: "user_status", nullable: true)]
2418
public ?Status $status = null;
2519

26-
/**
27-
* @ORM\Column(type="birthdate", nullable=true)
28-
*/
20+
#[ORM\Column(type: "birthdate", nullable: true)]
2921
public ?Birthdate $birthdate = null;
3022

31-
/**
32-
* @ORM\Column(type="phone_number", nullable=true)
33-
*/
23+
#[ORM\Column(type: "phone_number", nullable: true)]
3424
public ?PhoneNumber $contactPhoneNumber = null;
3525

36-
/**
37-
* @ORM\Column(type="phone_numbers", nullable=true)
38-
*/
26+
#[ORM\Column(type: "phone_numbers", nullable: true)]
3927
public ?PhoneNumbers $phoneNumbers = null;
4028

41-
/**
42-
* @ORM\Column(type="notifications", nullable=true)
43-
*/
29+
#[ORM\Column(type: "notifications", nullable:true)]
4430
public ?Notifications $notifications = null;
4531
}

0 commit comments

Comments
 (0)