Skip to content

Commit 12fa523

Browse files
committed
Fix unit test regression (no database)
1 parent 83762d1 commit 12fa523

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

.github/workflows/php.yml

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,37 @@ jobs:
4848
php-versions: ['8.1', '8.2', '8.3', '8.4']
4949

5050
steps:
51+
- name: Setup test MySQL database
52+
run: |
53+
sudo systemctl start mysql.service
54+
mysql -uroot -proot -e 'CREATE DATABASE IF NOT EXISTS simplesamlphp;'
55+
mysql -uroot -proot -e '
56+
CREATE TABLE IF NOT EXISTS `AttributeFromSQL` (
57+
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
58+
`uid` VARCHAR(100) NOT NULL,
59+
`sp` VARCHAR(250) DEFAULT "%",
60+
`attribute` VARCHAR(30) NOT NULL,
61+
`value` TEXT,
62+
`expires` DATE DEFAULT "9999-12-31",
63+
PRIMARY KEY (`id`)
64+
) DEFAULT CHARSET=utf8;
65+
CREATE USER IF NOT EXISTS `phpunit`@`localhost` IDENTIFIED BY "phpunit";
66+
GRANT ALL ON `simplesamlphp`.* TO `phpunit`@`localhost`;
67+
' simplesamlphp
68+
mysql -uroot -proot -e "
69+
INSERT INTO AttributeFromSQL (uid, sp, attribute, value) VALUES ('user@example.org', '%', 'eduPersonEntitlement', 'urn:mace:exampleIdP.org:demoservice:demo-admin');
70+
INSERT INTO AttributeFromSQL (uid, sp, attribute, value) VALUES ('user@example.org', 'https://idp.example.org/idp/shibboleth', 'eduPersonEntitlement', 'urn:mace:grnet.gr:eduroam:admin');
71+
INSERT INTO AttributeFromSQL (uid, sp, attribute, value) VALUES ('user@example.org', '%', 'eduPersonAffiliation', 'faculty');
72+
INSERT INTO AttributeFromSQL (uid, attribute, value) VALUES ('user@example.org', 'mail', 'user@example.org');
73+
INSERT INTO AttributeFromSQL (uid, attribute, value, expires) VALUES ('user@example.org', 'mail', 'marty@example.org', '2015-10-21');
74+
" simplesamlphp
75+
5176
- name: Setup PHP, with composer and extensions
5277
# https://github.com/shivammathur/setup-php
5378
uses: shivammathur/setup-php@v2
5479
with:
5580
php-version: ${{ matrix.php-versions }}
56-
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, posix, spl, xdebug, xml
81+
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, mysql, openssl, pcre, posix, spl, xdebug, xml
5782
tools: composer
5883
ini-values: error_reporting=E_ALL, pcov.directory=.
5984
coverage: pcov
@@ -112,7 +137,7 @@ jobs:
112137
# Should be the higest supported version, so we can use the newest tools
113138
php-version: '8.4'
114139
tools: composer, composer-require-checker, composer-unused
115-
extensions: ctype, date, dom, filter, hash, intl, mbstring, opcache, openssl, pcre, spl, xml
140+
extensions: ctype, date, dom, filter, hash, intl, mbstring, mysql, opcache, openssl, pcre, spl, xml
116141

117142
- name: Setup problem matchers for PHP
118143
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
@@ -140,8 +165,7 @@ jobs:
140165

141166
- name: Check code for unused dependencies in composer.json
142167
run: |
143-
composer-unused \
144-
--excludePackage=simplesamlphp/simplesamlphp-assets-jquery
168+
composer-unused
145169
146170
- name: PHP Code Sniffer
147171
run: vendor/bin/phpcs

0 commit comments

Comments
 (0)