From d3cc680e44b40f62d72d7f53e63954b10038fa78 Mon Sep 17 00:00:00 2001 From: Nurguly Ashyrov Date: Sun, 31 Jan 2021 17:48:08 +0400 Subject: [PATCH 01/38] learn github actions --- .github/workflows/test.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..16520306 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,11 @@ +name: learn-github-actions +on: [push] +jobs: + check-bats-version: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + - run: npm install -g bats + - run: bats -v + From 0d3566557ccbc35e8aa38e0536b11b6da428ab3d Mon Sep 17 00:00:00 2001 From: Nurguly Ashyrov Date: Sun, 31 Jan 2021 18:04:50 +0400 Subject: [PATCH 02/38] iterate 1 --- .github/workflows/test.yml | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 16520306..67edcfa8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,8 +4,27 @@ jobs: check-bats-version: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 - - run: npm install -g bats - - run: bats -v + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Node + uses: actions/setup-node@v2 + with: + node-version: '14' + check-lates: true + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '7.1' + ini-values: post_max_size=256M, max_execution_time=180 + coverage: none + tools: phpunit + + - name: Install Dependencies + - run: npm install + + - name: Check Versions + - run: node --version + - run: php --version + - run: composer --version From 862fdd643396914b81c79978dff54735db105802 Mon Sep 17 00:00:00 2001 From: Nurguly Ashyrov Date: Sun, 31 Jan 2021 18:08:10 +0400 Subject: [PATCH 03/38] iterate 2 --- .github/workflows/test.yml | 12 ++++++------ .travis.yml | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 67edcfa8..2576e2cb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,10 +21,10 @@ jobs: coverage: none tools: phpunit - - name: Install Dependencies - - run: npm install + # - name: Install Dependencies + # - run: npm install - - name: Check Versions - - run: node --version - - run: php --version - - run: composer --version + # - name: Check Versions + # - run: node --version + # - run: php --version + # - run: composer --version diff --git a/.travis.yml b/.travis.yml index cb3f5498..ea65ca11 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,3 +27,4 @@ script: branches: except: - /^v\d+\.\d+(\.\d+)?(-\S*)?$/ + - learn-github-actions From 2dcb58e27b68dc035ce096d602107db86e1b5266 Mon Sep 17 00:00:00 2001 From: Nurguly Ashyrov Date: Sun, 31 Jan 2021 18:10:35 +0400 Subject: [PATCH 04/38] iterate 3 --- .github/workflows/test.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2576e2cb..bc91560f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,7 +1,7 @@ name: learn-github-actions on: [push] jobs: - check-bats-version: + setup: runs-on: ubuntu-latest steps: - name: Checkout @@ -18,11 +18,9 @@ jobs: with: php-version: '7.1' ini-values: post_max_size=256M, max_execution_time=180 - coverage: none - tools: phpunit - # - name: Install Dependencies - # - run: npm install + - name: Install Dependencies + - run: npm install # - name: Check Versions # - run: node --version From 44444f035d366bfd04ce09cd6e3afe5f82370a0e Mon Sep 17 00:00:00 2001 From: Nurguly Ashyrov Date: Sun, 31 Jan 2021 18:11:58 +0400 Subject: [PATCH 05/38] iterate 4 --- .github/workflows/test.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bc91560f..123585d5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,5 +1,4 @@ name: learn-github-actions -on: [push] jobs: setup: runs-on: ubuntu-latest @@ -19,7 +18,7 @@ jobs: php-version: '7.1' ini-values: post_max_size=256M, max_execution_time=180 - - name: Install Dependencies + - name: Dependencies - run: npm install # - name: Check Versions From 5f4dfb9826cf342873fd7c42867f5a5d63f8be2a Mon Sep 17 00:00:00 2001 From: Nurguly Ashyrov Date: Sun, 31 Jan 2021 18:14:40 +0400 Subject: [PATCH 06/38] itereate 5 --- .github/workflows/test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 123585d5..9f33a375 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,5 @@ name: learn-github-actions +on: [push] jobs: setup: runs-on: ubuntu-latest @@ -19,7 +20,7 @@ jobs: ini-values: post_max_size=256M, max_execution_time=180 - name: Dependencies - - run: npm install + run: npm install # - name: Check Versions # - run: node --version From 6cbc13234e8ed49b6ddd4cdef0f062ccb665e542 Mon Sep 17 00:00:00 2001 From: Nurguly Ashyrov Date: Sun, 31 Jan 2021 18:38:13 +0400 Subject: [PATCH 07/38] iterate 6 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9f33a375..97bc4fd3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,7 +16,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '7.1' + php-version: '8.0' ini-values: post_max_size=256M, max_execution_time=180 - name: Dependencies From f90c6437ab6dab8387377ae78089b486fc6a23ed Mon Sep 17 00:00:00 2001 From: Nurguly Ashyrov Date: Sun, 31 Jan 2021 18:39:39 +0400 Subject: [PATCH 08/38] remove .travis.yml --- .travis.yml | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index ea65ca11..00000000 --- a/.travis.yml +++ /dev/null @@ -1,30 +0,0 @@ -language: php - -php: - - '7.2' - - '8.0' - -services: - - mysql - -before_install: - # disable xdebug, because it affects performance - - phpenv config-rm xdebug.ini - - # create our test database - - mysql -e "CREATE DATABASE IF NOT EXISTS processgraphql;" - - mysql -e "CREATE USER 'processgraphql'@'localhost' IDENTIFIED BY 'processgraphql';" - - mysql -e "GRANT ALL ON processgraphql.* to 'processgraphql'@'localhost';" - - mysql -e "FLUSH PRIVILEGES;" - - -install: - - composer install - -script: - - composer exec -v "phpunit --bootstrap test/bootstrap.php test" - -branches: - except: - - /^v\d+\.\d+(\.\d+)?(-\S*)?$/ - - learn-github-actions From b41f39eb560780dcb4ad5a2208ac7de3ea1dcbf0 Mon Sep 17 00:00:00 2001 From: Nurguly Ashyrov Date: Sun, 31 Jan 2021 19:19:15 +0400 Subject: [PATCH 09/38] iterate 7 --- .github/workflows/test.yml | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 97bc4fd3..1c8815f5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,8 +1,15 @@ -name: learn-github-actions +name: test on: [push] jobs: setup: runs-on: ubuntu-latest + strategy: + matrix: + include: + - php-version: 7.1 + phpunit: 7.5 + - php-version: 8.0 + phpunit: 9.5 steps: - name: Checkout uses: actions/checkout@v2 @@ -16,13 +23,8 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.0' - ini-values: post_max_size=256M, max_execution_time=180 + php-version: '${{ matrix.php-version }}' + tools: composer - name: Dependencies - run: npm install - - # - name: Check Versions - # - run: node --version - # - run: php --version - # - run: composer --version + run: echo ${{ matrix.phpunit }} From 8c48c4013c6de35b1b8409612ebbaa56f3c14162 Mon Sep 17 00:00:00 2001 From: Nurguly Ashyrov Date: Sun, 31 Jan 2021 19:21:27 +0400 Subject: [PATCH 10/38] iterate 8 --- .github/workflows/test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1c8815f5..97157edb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,4 +27,6 @@ jobs: tools: composer - name: Dependencies - run: echo ${{ matrix.phpunit }} + run: composer require@${{ matrix.phpunit }} + run: composer update + run: composer install From 67a579bec45b3fd047d804b5fb4b08f1ef076e11 Mon Sep 17 00:00:00 2001 From: Nurguly Ashyrov Date: Sun, 31 Jan 2021 19:24:26 +0400 Subject: [PATCH 11/38] iterate 9 --- .github/workflows/test.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 97157edb..52705d8f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,6 +27,7 @@ jobs: tools: composer - name: Dependencies - run: composer require@${{ matrix.phpunit }} - run: composer update - run: composer install + run: + - composer require@${{ matrix.phpunit }} + - composer update + - composer install From 47a5513d3b1a502f39eec8995c08b130e26dc8b1 Mon Sep 17 00:00:00 2001 From: Nurguly Ashyrov Date: Sun, 31 Jan 2021 19:26:51 +0400 Subject: [PATCH 12/38] iterate 10 --- .github/workflows/test.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 52705d8f..369e03be 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,7 +27,6 @@ jobs: tools: composer - name: Dependencies - run: - - composer require@${{ matrix.phpunit }} - - composer update - - composer install + - run: composer require@${{ matrix.phpunit }} + - run: composer update + - run: composer install From ef3ac8235355c8f54bb37dc1358cae87e94107ca Mon Sep 17 00:00:00 2001 From: Nurguly Ashyrov Date: Sun, 31 Jan 2021 19:29:52 +0400 Subject: [PATCH 13/38] iterate 11 --- .github/workflows/test.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 369e03be..1504cb4b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,6 +27,7 @@ jobs: tools: composer - name: Dependencies - - run: composer require@${{ matrix.phpunit }} - - run: composer update - - run: composer install + run: | + composer require@${{ matrix.phpunit }} + composer update + composer install From 1043230c60629c5143af9d3dd8375cad1f971159 Mon Sep 17 00:00:00 2001 From: Nurguly Ashyrov Date: Sun, 31 Jan 2021 19:30:56 +0400 Subject: [PATCH 14/38] iterate 12 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1504cb4b..00f48fd0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,6 +28,6 @@ jobs: - name: Dependencies run: | - composer require@${{ matrix.phpunit }} + composer require phpunit@${{ matrix.phpunit }} composer update composer install From 60bb7c15aedc1aba50e287fd93b313427f6f9df8 Mon Sep 17 00:00:00 2001 From: Nurguly Ashyrov Date: Sun, 31 Jan 2021 19:32:30 +0400 Subject: [PATCH 15/38] itereate 13 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 00f48fd0..30394938 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,6 +28,6 @@ jobs: - name: Dependencies run: | - composer require phpunit@${{ matrix.phpunit }} + composer require phpunit/phpunit@${{ matrix.phpunit }} composer update composer install From 704f486b5ad0f9136b7629a48b4258baf4c9a6e9 Mon Sep 17 00:00:00 2001 From: Nurguly Ashyrov Date: Sun, 31 Jan 2021 19:36:24 +0400 Subject: [PATCH 16/38] iterate 14 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 30394938..b52d8a97 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,6 +28,6 @@ jobs: - name: Dependencies run: | - composer require phpunit/phpunit@${{ matrix.phpunit }} + composer require phpunit/phpunit ^${{ matrix.phpunit }} --dev composer update composer install From d7bdde6ca1da68e427dd266013fb961796fb8039 Mon Sep 17 00:00:00 2001 From: Nurguly Ashyrov Date: Sun, 31 Jan 2021 19:43:51 +0400 Subject: [PATCH 17/38] iterate 15 --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b52d8a97..7c1dbbf4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,7 +7,7 @@ jobs: matrix: include: - php-version: 7.1 - phpunit: 7.5 + phpunit: 7.4 - php-version: 8.0 phpunit: 9.5 steps: @@ -30,4 +30,4 @@ jobs: run: | composer require phpunit/phpunit ^${{ matrix.phpunit }} --dev composer update - composer install + npm install From 709024ec9cf4ae2cb31729b2220c563c94b78df7 Mon Sep 17 00:00:00 2001 From: Nurguly Ashyrov Date: Sun, 31 Jan 2021 19:45:56 +0400 Subject: [PATCH 18/38] iterate 16 --- .github/workflows/test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7c1dbbf4..2fa10639 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,9 +7,9 @@ jobs: matrix: include: - php-version: 7.1 - phpunit: 7.4 - - php-version: 8.0 - phpunit: 9.5 + phpunit: 7.5 + # - php-version: 8.0 + # phpunit: 9.5 steps: - name: Checkout uses: actions/checkout@v2 @@ -28,6 +28,6 @@ jobs: - name: Dependencies run: | - composer require phpunit/phpunit ^${{ matrix.phpunit }} --dev + composer require phpunit/phpunit ${{ matrix.phpunit }} --dev composer update npm install From dda8727027bcfbfb9d21f64d64eb9cbab62fd3dd Mon Sep 17 00:00:00 2001 From: Nurguly Ashyrov Date: Sun, 31 Jan 2021 19:56:58 +0400 Subject: [PATCH 19/38] itereate 17 --- .github/workflows/test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2fa10639..355045d9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,8 +8,8 @@ jobs: include: - php-version: 7.1 phpunit: 7.5 - # - php-version: 8.0 - # phpunit: 9.5 + - php-version: 8.0 + phpunit: 9.5 steps: - name: Checkout uses: actions/checkout@v2 @@ -28,6 +28,6 @@ jobs: - name: Dependencies run: | - composer require phpunit/phpunit ${{ matrix.phpunit }} --dev - composer update + composer require phpunit/phpunit ^${{ matrix.phpunit }} --dev + composer update --with-all-dependencies npm install From 168d31076ab67b9680ff1e355665da4924618d51 Mon Sep 17 00:00:00 2001 From: Nurguly Ashyrov Date: Sun, 31 Jan 2021 20:01:23 +0400 Subject: [PATCH 20/38] iterate 18 --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 355045d9..1728745a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,6 +28,7 @@ jobs: - name: Dependencies run: | + rm composer.lock composer require phpunit/phpunit ^${{ matrix.phpunit }} --dev composer update --with-all-dependencies npm install From 452c70654545d9939099416d65830b75f330ab34 Mon Sep 17 00:00:00 2001 From: Nurguly Ashyrov Date: Sun, 31 Jan 2021 23:58:46 +0400 Subject: [PATCH 21/38] iterate 19 --- .github/workflows/test.yml | 14 +++- test/site/config.php | 129 ++++++++++++++++++------------------- 2 files changed, 77 insertions(+), 66 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1728745a..0f50a8e6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,8 +1,9 @@ name: test on: [push] jobs: - setup: + test: runs-on: ubuntu-latest + contiainer: ubuntu:latest strategy: matrix: include: @@ -10,6 +11,14 @@ jobs: phpunit: 7.5 - php-version: 8.0 phpunit: 9.5 + services: + mysql: + image: mysql:8.0.23 + env: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: processgraphql + MYSQL_USER: processgraphql + MYSQL_PASSWORD: processgraphql steps: - name: Checkout uses: actions/checkout@v2 @@ -32,3 +41,6 @@ jobs: composer require phpunit/phpunit ^${{ matrix.phpunit }} --dev composer update --with-all-dependencies npm install + + - name: Test + run: npm test diff --git a/test/site/config.php b/test/site/config.php index af002c06..b91caaf9 100644 --- a/test/site/config.php +++ b/test/site/config.php @@ -1,22 +1,24 @@ useFunctionsAPI = true; - - - /*** 7. DATABASE ********************************************************************************/ /** * Database character set - * - * utf8 is the only recommended value for this. * - * Note that you should probably not add/change this on an existing site. i.e. don't add this to - * an existing ProcessWire installation without asking how in the ProcessWire forums. + * utf8 is the only recommended value for this. + * + * Note that you should probably not add/change this on an existing site. i.e. don't add this to + * an existing ProcessWire installation without asking how in the ProcessWire forums. * */ -$config->dbCharset = 'utf8'; +$config->dbCharset = "utf8"; /** * Database engine - * + * * May be 'InnoDB' or 'MyISAM'. Avoid changing this after install. - * + * */ -$config->dbEngine = 'MyISAM'; +$config->dbEngine = "MyISAM"; /** * Allow MySQL query caching? - * + * * Set to false to to disable query caching. This will make everything run slower so should * only used for DB debugging purposes. - * + * * @var bool * */ @@ -83,43 +82,43 @@ /** * MySQL database exec path - * + * * Path to mysql/mysqldump commands on the file system * * This enables faster backups and imports when available. * * Example: /usr/bin/ * Example: /Applications/MAMP/Library/bin/ - * + * * @param string * */ -$config->dbPath = ''; +$config->dbPath = ""; /** * Force lowercase tables? - * + * * Force any created field_* tables to be lowercase. * Recommend value is true except for existing installations that already have mixed case tables. - * + * */ $config->dbLowercaseTables = true; /** * Installer: Database Configuration - * + * */ -$config->dbHost = '127.0.0.1'; -$config->dbName = 'processgraphql'; -$config->dbUser = 'processgraphql'; -$config->dbPass = 'processgraphql'; -$config->dbPort = '3306'; +$config->dbHost = "mysql"; +$config->dbName = "processgraphql"; +$config->dbUser = "processgraphql"; +$config->dbPass = "processgraphql"; +$config->dbPort = "3306"; /** * Database init command (PDO::MYSQL_ATTR_INIT_COMMAND) * * Note: Placeholder "{charset}" gets automatically replaced with $config->dbCharset. - * + * * @var string * */ @@ -127,57 +126,57 @@ /** * Set or adjust SQL mode per MySQL version - * - * Array indexes are minimum MySQL version mode applies to. Array values are - * the names of the mode(s) to apply. If value is preceded with "remove:" the mode will - * be removed, or if preceded with "add:" the mode will be added. If neither is present + * + * Array indexes are minimum MySQL version mode applies to. Array values are + * the names of the mode(s) to apply. If value is preceded with "remove:" the mode will + * be removed, or if preceded with "add:" the mode will be added. If neither is present * then the mode will be set exactly as given. To specify more than one SQL mode for the - * value, separate them by commas (CSV). To specify multiple statements for the same + * value, separate them by commas (CSV). To specify multiple statements for the same * version, separate them with a slash "/". - * + * * ~~~~~ * array("5.7.0" => "remove:STRICT_TRANS_TABLES,ONLY_FULL_GROUP_BY/add:NO_ZERO_DATE") * ~~~~~ - * + * * @var array - * + * */ -$config->dbSqlModes = array( - "5.7.0" => "remove:STRICT_TRANS_TABLES,ONLY_FULL_GROUP_BY" -); +$config->dbSqlModes = [ + "5.7.0" => "remove:STRICT_TRANS_TABLES,ONLY_FULL_GROUP_BY", +]; /** * A key=>value array of any additional driver-specific connection options. - * + * * @var array - * + * */ -$config->dbOptions = array(); +$config->dbOptions = []; /** * Optional DB socket config for sites that need it (for most you should exclude this) - * + * * @var string * */ -$config->dbSocket = ''; +$config->dbSocket = ""; /** * Maximum number of queries WireDatabasePDO will log in memory (when $config->debug is enabled) - * + * * @var int - * + * */ $config->dbQueryLogMax = 500; /** * Remove 4-byte characters (like emoji) when dbEngine is not utf8mb4? - * + * * When charset is not “utf8mb4” and this value is true, 4-byte UTF-8 characters are stripped - * out of inserted values when possible. Note that this can add some overhead to INSERTs. - * + * out of inserted values when possible. Note that this can add some overhead to INSERTs. + * * @var bool - * + * */ $config->dbStripMB4 = false; @@ -197,9 +196,9 @@ * Installer: User Authentication Salt * * Must be retained if you migrate your site from one server to another - * + * */ -$config->userAuthSalt = 'f4e0b5d144f474df44d7a4a0334921bf'; +$config->userAuthSalt = "f4e0b5d144f474df44d7a4a0334921bf"; /** * An array of users we use for testing @@ -207,8 +206,8 @@ * @var array */ $config->testUsers = [ - 'admin' => 'skyscrapers-admin', - 'editor' => 'skyscrapers-editor-123', + "admin" => "skyscrapers-admin", + "editor" => "skyscrapers-editor-123", ]; /** From c36269dfaa69252014b2e0e8ee530a56b8963033 Mon Sep 17 00:00:00 2001 From: Nurguly Ashyrov Date: Sun, 31 Jan 2021 23:59:42 +0400 Subject: [PATCH 22/38] iterate 20 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0f50a8e6..28959c2f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,7 +3,7 @@ on: [push] jobs: test: runs-on: ubuntu-latest - contiainer: ubuntu:latest + container: ubuntu:latest strategy: matrix: include: From 9a87aef29cfedad4cb0b120ea028a7abe42ff4cb Mon Sep 17 00:00:00 2001 From: Nurguly Ashyrov Date: Mon, 1 Feb 2021 22:24:21 +0400 Subject: [PATCH 23/38] itereate 20 --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 28959c2f..2addf126 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,7 +3,7 @@ on: [push] jobs: test: runs-on: ubuntu-latest - container: ubuntu:latest + container: ubuntu:bionic strategy: matrix: include: @@ -27,7 +27,7 @@ jobs: uses: actions/setup-node@v2 with: node-version: '14' - check-lates: true + check-latest: true - name: Setup PHP uses: shivammathur/setup-php@v2 From 8476b661e1e96c45717bdf12b7fe77ea467c3191 Mon Sep 17 00:00:00 2001 From: Nurguly Ashyrov Date: Mon, 1 Feb 2021 22:32:54 +0400 Subject: [PATCH 24/38] iterate 21 --- .github/workflows/test.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2addf126..56e97cd3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,7 +3,7 @@ on: [push] jobs: test: runs-on: ubuntu-latest - container: ubuntu:bionic + container: ubuntu:latest strategy: matrix: include: @@ -29,6 +29,11 @@ jobs: node-version: '14' check-latest: true + - name: Install Sudo + run: | + apt-get update + apt-get install sudo + - name: Setup PHP uses: shivammathur/setup-php@v2 with: From d0d74a94aef50f66dd419b7ad124a88871ff1fa4 Mon Sep 17 00:00:00 2001 From: Nurguly Ashyrov Date: Mon, 1 Feb 2021 22:36:40 +0400 Subject: [PATCH 25/38] iterate 22 --- .github/workflows/test.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 56e97cd3..4825e6ef 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,11 +29,6 @@ jobs: node-version: '14' check-latest: true - - name: Install Sudo - run: | - apt-get update - apt-get install sudo - - name: Setup PHP uses: shivammathur/setup-php@v2 with: From 27e3fdbbd6ff5a03661daeec0b31d017585e9f64 Mon Sep 17 00:00:00 2001 From: Nurguly Ashyrov Date: Mon, 1 Feb 2021 22:45:27 +0400 Subject: [PATCH 26/38] iterate 23 --- .github/workflows/test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4825e6ef..77346965 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,7 +3,6 @@ on: [push] jobs: test: runs-on: ubuntu-latest - container: ubuntu:latest strategy: matrix: include: @@ -19,6 +18,8 @@ jobs: MYSQL_DATABASE: processgraphql MYSQL_USER: processgraphql MYSQL_PASSWORD: processgraphql + ports: + - 3306:3306 steps: - name: Checkout uses: actions/checkout@v2 From d23df38d44c3a1137c5b29ca4e9f85a81a0a6793 Mon Sep 17 00:00:00 2001 From: Nurguly Ashyrov Date: Mon, 1 Feb 2021 22:49:47 +0400 Subject: [PATCH 27/38] iterate 24 --- test/site/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/site/config.php b/test/site/config.php index b91caaf9..5b6d4a35 100644 --- a/test/site/config.php +++ b/test/site/config.php @@ -108,7 +108,7 @@ * Installer: Database Configuration * */ -$config->dbHost = "mysql"; +$config->dbHost = "localhost"; $config->dbName = "processgraphql"; $config->dbUser = "processgraphql"; $config->dbPass = "processgraphql"; From 67017de7fc5788031c6894495e2a8700b4673171 Mon Sep 17 00:00:00 2001 From: Nurguly Ashyrov Date: Mon, 1 Feb 2021 22:53:23 +0400 Subject: [PATCH 28/38] itereate 25 --- .github/workflows/test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 77346965..b3a27b1a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,6 +18,9 @@ jobs: MYSQL_DATABASE: processgraphql MYSQL_USER: processgraphql MYSQL_PASSWORD: processgraphql + options: >- + -p 3306:3306 + ports: - 3306:3306 steps: From 5e08764005b52d08ada2eaac7afc9c87e541fe0c Mon Sep 17 00:00:00 2001 From: Nurguly Ashyrov Date: Mon, 1 Feb 2021 23:05:16 +0400 Subject: [PATCH 29/38] iterate 26 --- .github/workflows/test.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b3a27b1a..a294228a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,8 +6,8 @@ jobs: strategy: matrix: include: - - php-version: 7.1 - phpunit: 7.5 + # - php-version: 7.1 + # phpunit: 7.5 - php-version: 8.0 phpunit: 9.5 services: @@ -18,9 +18,6 @@ jobs: MYSQL_DATABASE: processgraphql MYSQL_USER: processgraphql MYSQL_PASSWORD: processgraphql - options: >- - -p 3306:3306 - ports: - 3306:3306 steps: From ece5056f73298c13f606ff4cb71722872b3e50f6 Mon Sep 17 00:00:00 2001 From: Nurguly Ashyrov Date: Mon, 1 Feb 2021 23:07:44 +0400 Subject: [PATCH 30/38] iterate 27 --- test/site/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/site/config.php b/test/site/config.php index 5b6d4a35..5dc1ba24 100644 --- a/test/site/config.php +++ b/test/site/config.php @@ -108,7 +108,7 @@ * Installer: Database Configuration * */ -$config->dbHost = "localhost"; +$config->dbHost = "127.0.0.1"; $config->dbName = "processgraphql"; $config->dbUser = "processgraphql"; $config->dbPass = "processgraphql"; From 1ff2d240ebfd2193eb55d7146faad3030850e715 Mon Sep 17 00:00:00 2001 From: Nurguly Ashyrov Date: Mon, 1 Feb 2021 23:23:55 +0400 Subject: [PATCH 31/38] iterate 30 --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a294228a..77346965 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,8 +6,8 @@ jobs: strategy: matrix: include: - # - php-version: 7.1 - # phpunit: 7.5 + - php-version: 7.1 + phpunit: 7.5 - php-version: 8.0 phpunit: 9.5 services: From 19ee23c11987633982cd4090cdf9796361de7a6e Mon Sep 17 00:00:00 2001 From: Nurguly Ashyrov Date: Tue, 2 Feb 2021 06:05:33 +0400 Subject: [PATCH 32/38] iterate 31 --- .github/workflows/test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 77346965..13059f1e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,11 +8,13 @@ jobs: include: - php-version: 7.1 phpunit: 7.5 + mysql: 5.7.33 - php-version: 8.0 phpunit: 9.5 + mysql: 8.0.23 services: mysql: - image: mysql:8.0.23 + image: mysql:${{ matrix.mysql }} env: MYSQL_ROOT_PASSWORD: root MYSQL_DATABASE: processgraphql From acb23bfde34a9b429f9cd4544cfbf21719a3b5bc Mon Sep 17 00:00:00 2001 From: Nurguly Ashyrov Date: Tue, 2 Feb 2021 06:08:58 +0400 Subject: [PATCH 33/38] iterate 33 --- .github/workflows/test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 13059f1e..27380613 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,12 +6,12 @@ jobs: strategy: matrix: include: - - php-version: 7.1 + - php-version: 7.2 phpunit: 7.5 mysql: 5.7.33 - - php-version: 8.0 - phpunit: 9.5 - mysql: 8.0.23 + # - php-version: 8.0 + # phpunit: 9.5 + # mysql: 8.0.23 services: mysql: image: mysql:${{ matrix.mysql }} From cbd87847d031d578f3db03b2c4e1d4fdd0fd2d12 Mon Sep 17 00:00:00 2001 From: Nurguly Ashyrov Date: Tue, 2 Feb 2021 06:19:34 +0400 Subject: [PATCH 34/38] iterate 34 --- test/{Interface => Interfaces}/PageTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename test/{Interface => Interfaces}/PageTest.php (96%) diff --git a/test/Interface/PageTest.php b/test/Interfaces/PageTest.php similarity index 96% rename from test/Interface/PageTest.php rename to test/Interfaces/PageTest.php index 19e4d320..b82644cb 100644 --- a/test/Interface/PageTest.php +++ b/test/Interfaces/PageTest.php @@ -1,6 +1,6 @@ Date: Tue, 2 Feb 2021 06:38:20 +0400 Subject: [PATCH 35/38] iterate 35 --- test/Field/Mutation/CreatePage/CaseTwoTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/test/Field/Mutation/CreatePage/CaseTwoTest.php b/test/Field/Mutation/CreatePage/CaseTwoTest.php index d5c75e41..7e4d2e1c 100644 --- a/test/Field/Mutation/CreatePage/CaseTwoTest.php +++ b/test/Field/Mutation/CreatePage/CaseTwoTest.php @@ -36,6 +36,7 @@ public function testValue() ]; $res = self::execute($query, $variables); $newBuildingSky = Utils::pages()->get("name=$name"); + \ProcessWire\GraphQL\logArr($res); self::assertEquals( 1, count($res->errors), From c66ad59df0c07374e9b6972cb626ec06528a78b8 Mon Sep 17 00:00:00 2001 From: Nurguly Ashyrov Date: Tue, 2 Feb 2021 07:38:26 +0400 Subject: [PATCH 36/38] itereate 36 --- src/Permissions.php | 56 +++++++++++-------- .../Field/Mutation/CreatePage/CaseTwoTest.php | 18 ++++-- 2 files changed, 47 insertions(+), 27 deletions(-) diff --git a/src/Permissions.php b/src/Permissions.php index e1f4ff42..8ddeff2b 100644 --- a/src/Permissions.php +++ b/src/Permissions.php @@ -7,14 +7,14 @@ class Permissions { - public const pageAddPermission = 'page-add'; - public const pageCreatePermission = 'page-create'; - public const pageDeletePermission = 'page-delete'; - public const pageEditPermission = 'page-edit'; - public const pageMovePermission = 'page-move'; - public const pageViewPermission = 'page-view'; - public const pageEditCreatedPermission = 'page-edit-created'; - public const pageEditTrashCreatedPermission = 'page-edit-trash-created'; + public const pageAddPermission = "page-add"; + public const pageCreatePermission = "page-create"; + public const pageDeletePermission = "page-delete"; + public const pageEditPermission = "page-edit"; + public const pageMovePermission = "page-move"; + public const pageViewPermission = "page-view"; + public const pageEditCreatedPermission = "page-edit-created"; + public const pageEditTrashCreatedPermission = "page-edit-trash-created"; /** * Checks if the page using this template can be viewed by the current user. @@ -60,23 +60,27 @@ public static function canCreate(Template $template) } // can't create if allowed parents are not legal - if ($template->noParents == 0 && count($template->parentTemplates)) { - + if (!$template->noParents && count($template->parentTemplates)) { // filter out the parents that has noChildren checked or // has configured childTemplates without the target template - $parentTemplates = array_filter($template->parentTemplates, function ($templateId) use ($template) { + $parentTemplates = array_filter($template->parentTemplates, function ( + $templateId + ) use ($template) { $parentTemplate = Utils::templates()->get($templateId); if ($parentTemplate->noChildren) { return false; } - if (count($parentTemplate->childTemplates) && !in_array($template->id, $parentTemplate->childTemplates)) { + if ( + count($parentTemplate->childTemplates) && + !in_array($template->id, $parentTemplate->childTemplates) + ) { return false; } return true; }); // get templates that user can add pages to - $addTemplates = self::getAddTemplates()->explode('id'); + $addTemplates = self::getAddTemplates()->explode("id"); if (!count(array_intersect($addTemplates, $parentTemplates))) { return false; } @@ -219,7 +223,11 @@ public static function canAdd(Template $template) // can't add a page if the allowed childTemplates are not legal if ($template->noChildren == 0 && count($template->childTemplates)) { - if (!count(array_intersect(self::getTemplateIds(), $template->childTemplates))) { + if ( + !count( + array_intersect(self::getTemplateIds(), $template->childTemplates) + ) + ) { return false; } } @@ -251,7 +259,7 @@ public static function canAdd(Template $template) */ public static function canEditField(Field $field, Template $template) { - return self::hasFieldPermission('edit', $field, $template); + return self::hasFieldPermission("edit", $field, $template); } /** @@ -263,7 +271,7 @@ public static function canEditField(Field $field, Template $template) */ public static function canViewField(Field $field, Template $template) { - return self::hasFieldPermission('view', $field, $template); + return self::hasFieldPermission("view", $field, $template); } /** @@ -274,8 +282,11 @@ public static function canViewField(Field $field, Template $template) * @param Template $template The context of the field. * @return boolean Returns true if user has rights and false otherwise */ - public static function hasFieldPermission(string $permission, Field $field, Template $template) - { + public static function hasFieldPermission( + string $permission, + Field $field, + Template $template + ) { $user = Utils::user(); // can view/edit a field if superuser @@ -289,7 +300,7 @@ public static function hasFieldPermission(string $permission, Field $field, Temp return false; } - $roles = $permission . 'Roles'; + $roles = $permission . "Roles"; foreach ($user->roles as $role) { if (in_array($role->id, $field->$roles)) { @@ -300,7 +311,6 @@ public static function hasFieldPermission(string $permission, Field $field, Temp return false; } - /** * Tells if the template or field has access control defined. * @@ -309,7 +319,7 @@ public static function hasFieldPermission(string $permission, Field $field, Temp */ public static function definesAccess($context) { - return (boolean) $context->useRoles; + return (bool) $context->useRoles; } /** @@ -320,7 +330,7 @@ public static function definesAccess($context) public static function getTemplates() { $templates = Utils::templates(); - $legalTemplateNames = implode('|', Utils::module()->legalTemplates); + $legalTemplateNames = implode("|", Utils::module()->legalTemplates); return $templates->find("name=$legalTemplateNames"); } @@ -331,7 +341,7 @@ public static function getTemplates() */ public static function getTemplateIds() { - return array_merge([], self::getTemplates()->explode('id')); + return array_merge([], self::getTemplates()->explode("id")); } public static function filterTemplatesByPermission($predicator) diff --git a/test/Field/Mutation/CreatePage/CaseTwoTest.php b/test/Field/Mutation/CreatePage/CaseTwoTest.php index 7e4d2e1c..1b68bee2 100644 --- a/test/Field/Mutation/CreatePage/CaseTwoTest.php +++ b/test/Field/Mutation/CreatePage/CaseTwoTest.php @@ -36,16 +36,26 @@ public function testValue() ]; $res = self::execute($query, $variables); $newBuildingSky = Utils::pages()->get("name=$name"); - \ProcessWire\GraphQL\logArr($res); self::assertEquals( - 1, + 2, count($res->errors), - "createSkyscraper does not exist if allowed parent page is not legal." + // "createSkyscraper does not exist if allowed parent page is not legal." + "Should have two errors." + ); + self::assertStringContainsString( + "SkyscraperCreateInput", + $res->errors[0]->message, + "'SkyscraperCreateInput' type should not exist." + ); + self::assertStringContainsString( + "createSkyscraper", + $res->errors[1]->message, + "'createSkyscraper' field should not exist." ); self::assertInstanceOf( NullPage::class, $newBuildingSky, - "createSkyscraper does not create a page." + "'createSkyscraper' does not create a page." ); } } From aa606eee870cd4cd045a212b6857421e394541e9 Mon Sep 17 00:00:00 2001 From: Nurguly Ashyrov Date: Tue, 2 Feb 2021 07:42:03 +0400 Subject: [PATCH 37/38] iterate 37 --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 27380613..40075f7d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,9 +9,9 @@ jobs: - php-version: 7.2 phpunit: 7.5 mysql: 5.7.33 - # - php-version: 8.0 - # phpunit: 9.5 - # mysql: 8.0.23 + - php-version: 8.0 + phpunit: 9.5 + mysql: 8.0.23 services: mysql: image: mysql:${{ matrix.mysql }} From e8b649775520fdb8d9fc05a5a43195f78b24cccd Mon Sep 17 00:00:00 2001 From: Nurguly Ashyrov Date: Tue, 2 Feb 2021 21:36:19 +0400 Subject: [PATCH 38/38] iterate 39 --- .github/workflows/test.yml | 2 +- Readme.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 40075f7d..a8d37ee9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: test +name: Test on: [push] jobs: test: diff --git a/Readme.md b/Readme.md index c5295464..a3f36ceb 100644 --- a/Readme.md +++ b/Readme.md @@ -1,6 +1,6 @@ # ProcessGraphQL -[![Travis-CI Status][travis-ci-badge]][travis-ci] +[![Test Status](https://github.com/dadish/ProcessGraphQL/workflows/Test/badge.svg)](https://github.com/dadish/ProcessGraphQL/actions) [GraphQL][graphql] for [ProcessWire][pw].