Skip to content

Commit

Permalink
avoid heredoc to test in PHP 7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
hrach committed Dec 2, 2023
1 parent f2c05f8 commit b1d03fe
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 34 deletions.
18 changes: 8 additions & 10 deletions tests/cases/PostgreSqlMultiQueryParserTest.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,14 @@ class PostgreSqlMultiQueryParserTest extends TestCase
$parser = new PostgreSqlMultiQueryParser();
$queries = iterator_to_array($parser->parseFile(__DIR__ . '/data/postgres.sql'));
Assert::count(66, $queries);
Assert::same(<<<SQL
CREATE FUNCTION "book_collections_before"() RETURNS TRIGGER AS
\$BODY$
BEGIN
NEW."updated_at" = NOW();
return NEW;
END;
\$BODY$
LANGUAGE 'plpgsql' VOLATILE
SQL, $queries[16]);
Assert::same("CREATE FUNCTION \"book_collections_before\"() RETURNS TRIGGER AS
\$BODY$
BEGIN
NEW.\"updated_at\" = NOW();
return NEW;
END;
\$BODY$
LANGUAGE 'plpgsql' VOLATILE", $queries[16]);
}
}

Expand Down
46 changes: 22 additions & 24 deletions tests/cases/SqlServerMultiQueryParserTest.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,28 @@ class SqlServerMultiQueryParserTest extends TestCase
$parser = new SqlServerMultiQueryParser();
$queries = iterator_to_array($parser->parseFile(__DIR__ . '/data/sqlserver.sql'));
Assert::count(69, $queries);
Assert::same(<<<SQL
CREATE TRIGGER mydatabase.trigger_book_stats
ON yourtable.books
AFTER INSERT, DELETE
AS
BEGIN
SET NOCOUNT ON;
INSERT INTO yourtable.book_stats(
book_id,
string_value
)
SELECT
i.book_id,
'INS'
FROM
inserted i
UNION ALL
SELECT
d.book_id,
'DEL'
FROM
deleted d;
END
SQL, $queries[67]);
Assert::same("CREATE TRIGGER mydatabase.trigger_book_stats
ON yourtable.books
AFTER INSERT, DELETE
AS
BEGIN
SET NOCOUNT ON;
INSERT INTO yourtable.book_stats(
book_id,
string_value
)
SELECT
i.book_id,
'INS'
FROM
inserted i
UNION ALL
SELECT
d.book_id,
'DEL'
FROM
deleted d;
END", $queries[67]);
}
}

Expand Down

0 comments on commit b1d03fe

Please sign in to comment.