Skip to content

Commit

Permalink
Added tests for MSSQL and Postgresql for BackedEnum + reworked code s…
Browse files Browse the repository at this point in the history
…tyle of previous changes
  • Loading branch information
Zazimou authored and datronjzima committed Feb 1, 2024
1 parent 7a12611 commit 55ed3cf
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 22 deletions.
8 changes: 4 additions & 4 deletions tests/db/mssql-data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ SET IDENTITY_INSERT tags OFF;
DBCC checkident ('tags', reseed, 3) WITH NO_INFOMSGS;

SET IDENTITY_INSERT books ON;
INSERT INTO books (id, author_id, translator_id, title, next_part, publisher_id, published_at, price, price_currency) VALUES (1, 1, 1, 'Book 1', NULL, 1, '2021-12-14 21:10:04', 50, 'CZK');
INSERT INTO books (id, author_id, translator_id, title, next_part, publisher_id, published_at, price, price_currency) VALUES (2, 1, NULL, 'Book 2', NULL, 2, '2021-12-14 21:10:02', 150, 'CZK');
INSERT INTO books (id, author_id, translator_id, title, next_part, publisher_id, published_at, price, price_currency) VALUES (3, 2, 2, 'Book 3', NULL, 3, '2021-12-14 21:10:03', 20, 'CZK');
INSERT INTO books (id, author_id, translator_id, title, next_part, publisher_id, published_at, price, price_currency) VALUES (4, 2, 2, 'Book 4', 3, 1, '2021-12-14 21:10:01', 220, 'CZK');
INSERT INTO books (id, author_id, translator_id, title, next_part, publisher_id, published_at, genre, price, price_currency) VALUES (1, 1, 1, 'Book 1', NULL, 1, '2021-12-14 21:10:04', 'sciFi', 50, 'CZK');
INSERT INTO books (id, author_id, translator_id, title, next_part, publisher_id, published_at, genre, price, price_currency) VALUES (2, 1, NULL, 'Book 2', NULL, 2, '2021-12-14 21:10:02', 'horror', 150, 'CZK');
INSERT INTO books (id, author_id, translator_id, title, next_part, publisher_id, published_at, genre, price, price_currency) VALUES (3, 2, 2, 'Book 3', NULL, 3, '2021-12-14 21:10:03', 'thriller', 20, 'CZK');
INSERT INTO books (id, author_id, translator_id, title, next_part, publisher_id, published_at, genre, price, price_currency) VALUES (4, 2, 2, 'Book 4', 3, 1, '2021-12-14 21:10:01', 'romance', 220, 'CZK');
SET IDENTITY_INSERT books OFF;

DBCC checkident ('books', reseed, 4) WITH NO_INFOMSGS;
Expand Down
1 change: 1 addition & 0 deletions tests/db/mssql-init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ CREATE TABLE books
next_part int,
publisher_id int NOT NULL,
published_at datetimeoffset NOT NULL,
genre varchar(20) NOT NULL,
printed_at datetimeoffset,
ean_id int,
price int,
Expand Down
16 changes: 4 additions & 12 deletions tests/db/mysql-data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,10 @@ INSERT INTO tags (id, name, is_global) VALUES (1, 'Tag 1', 'y');
INSERT INTO tags (id, name, is_global) VALUES (2, 'Tag 2', 'y');
INSERT INTO tags (id, name, is_global) VALUES (3, 'Tag 3', 'n');

INSERT INTO books (id, author_id, translator_id, title, next_part, publisher_id, genre, published_at, price,
price_currency)
VALUES (1, 1, 1, 'Book 1', NULL, 1, 'sciFi', '2021-12-14 21:10:04', 50, 'CZK');
INSERT INTO books (id, author_id, translator_id, title, next_part, publisher_id, genre, published_at, price,
price_currency)
VALUES (2, 1, NULL, 'Book 2', NULL, 2, 'horror', '2021-12-14 21:10:02', 150, 'CZK');
INSERT INTO books (id, author_id, translator_id, title, next_part, publisher_id, genre, published_at, price,
price_currency)
VALUES (3, 2, 2, 'Book 3', NULL, 3, 'thriller', '2021-12-14 21:10:03', 20, 'CZK');
INSERT INTO books (id, author_id, translator_id, title, next_part, publisher_id, genre, published_at, price,
price_currency)
VALUES (4, 2, 2, 'Book 4', 3, 1, 'romance', '2021-12-14 21:10:01', 220, 'CZK');
INSERT INTO books (id, author_id, translator_id, title, next_part, publisher_id, genre, published_at, price, price_currency) VALUES (1, 1, 1, 'Book 1', NULL, 1, 'sciFi', '2021-12-14 21:10:04', 50, 'CZK');
INSERT INTO books (id, author_id, translator_id, title, next_part, publisher_id, genre, published_at, price, price_currency) VALUES (2, 1, NULL, 'Book 2', NULL, 2, 'horror', '2021-12-14 21:10:02', 150, 'CZK');
INSERT INTO books (id, author_id, translator_id, title, next_part, publisher_id, genre, published_at, price, price_currency) VALUES (3, 2, 2, 'Book 3', NULL, 3, 'thriller', '2021-12-14 21:10:03', 20, 'CZK');
INSERT INTO books (id, author_id, translator_id, title, next_part, publisher_id, genre, published_at, price, price_currency) VALUES (4, 2, 2, 'Book 4', 3, 1, 'romance', '2021-12-14 21:10:01', 220, 'CZK');

INSERT INTO books_x_tags (book_id, tag_id) VALUES (1, 1);
INSERT INTO books_x_tags (book_id, tag_id) VALUES (1, 2);
Expand Down
2 changes: 1 addition & 1 deletion tests/db/mysql-init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ CREATE TABLE books
title varchar(50) NOT NULL,
next_part int,
publisher_id int NOT NULL,
genre varchar(20) NOT NULL,
genre varchar(20) NOT NULL,
published_at DATETIME NOT NULL,
printed_at DATETIME,
ean_id int,
Expand Down
8 changes: 4 additions & 4 deletions tests/db/pgsql-data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ INSERT INTO "tags" ("id", "name", "is_global") VALUES (3, 'Tag 3', 'n');
SELECT setval('tags_id_seq', 3, true);


INSERT INTO "books" ("id", "author_id", "translator_id", "title", "next_part", "publisher_id", "published_at", "price", "price_currency") VALUES (1, 1, 1, 'Book 1', NULL, 1, '2021-12-14 21:10:04', 50, 'CZK');
INSERT INTO "books" ("id", "author_id", "translator_id", "title", "next_part", "publisher_id", "published_at", "price", "price_currency") VALUES (2, 1, NULL, 'Book 2', NULL, 2, '2021-12-14 21:10:02', 150, 'CZK');
INSERT INTO "books" ("id", "author_id", "translator_id", "title", "next_part", "publisher_id", "published_at", "price", "price_currency") VALUES (3, 2, 2, 'Book 3', NULL, 3, '2021-12-14 21:10:03', 20, 'CZK');
INSERT INTO "books" ("id", "author_id", "translator_id", "title", "next_part", "publisher_id", "published_at", "price", "price_currency") VALUES (4, 2, 2, 'Book 4', 3, 1, '2021-12-14 21:10:01', 220, 'CZK');
INSERT INTO "books" ("id", "author_id", "translator_id", "title", "next_part", "publisher_id", "published_at", "genre", "price", "price_currency") VALUES (1, 1, 1, 'Book 1', NULL, 1, '2021-12-14 21:10:04', 'sciFi', 50, 'CZK');
INSERT INTO "books" ("id", "author_id", "translator_id", "title", "next_part", "publisher_id", "published_at", "genre", "price", "price_currency") VALUES (2, 1, NULL, 'Book 2', NULL, 2, '2021-12-14 21:10:02', 'horror', 150, 'CZK');
INSERT INTO "books" ("id", "author_id", "translator_id", "title", "next_part", "publisher_id", "published_at", "genre", "price", "price_currency") VALUES (3, 2, 2, 'Book 3', NULL, 3, '2021-12-14 21:10:03', 'thriller', 20, 'CZK');
INSERT INTO "books" ("id", "author_id", "translator_id", "title", "next_part", "publisher_id", "published_at", "genre", "price", "price_currency") VALUES (4, 2, 2, 'Book 4', 3, 1, '2021-12-14 21:10:01', 'romance', 220, 'CZK');

SELECT setval('books_id_seq', 4, true);

Expand Down
1 change: 1 addition & 0 deletions tests/db/pgsql-init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ CREATE TABLE "books"
"next_part" int,
"publisher_id" int NOT NULL,
"published_at" TIMESTAMP NOT NULL,
"genre" varchar(20) NOT NULL,
"printed_at" TIMESTAMP,
"ean_id" int,
"price" int,
Expand Down
2 changes: 1 addition & 1 deletion tests/inc/model/book/Book.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* @property Book|null $previousPart {1:1 Book::$nextPart}
* @property Ean|null $ean {1:1 Ean::$book, isMain=true, cascade=[persist, remove]}
* @property Publisher $publisher {m:1 Publisher::$books}
* @property GenreEnum $genre {default GenreEnum::FANTASY}
* @property GenreEnum $genre {default GenreEnum::FANTASY}
* @property DateTimeImmutable $publishedAt {default "2021-12-31 23:59:59"}
* @property DateTimeImmutable|null $printedAt
* @property Money|null $price {embeddable}
Expand Down

0 comments on commit 55ed3cf

Please sign in to comment.