-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Phpcs Baseline testing #24
Closed
Closed
Changes from all commits
Commits
Show all changes
231 commits
Select commit
Hold shift + click to select a range
cf245fa
Fix PHPCS issue
kamleshluhana 378f37b
Added Coding Standard action.yml file
kamleshluhana 851cfe8
Verify PHPCs baseline action
kamleshluhana b63edc4
Verify PHPCs baseline action
kamleshluhana 54c3279
Verify PHPCs baseline action
kamleshluhana 84e0efb
Verify PHPCs baseline action
kamleshluhana c43ca7f
Verify PHPCs baseline action
kamleshluhana 761f63c
Verify PHPCs baseline action
kamleshluhana 7c7bbc3
Verify PHPCs baseline action
kamleshluhana dceb3d9
Verify PHPCs baseline action
kamleshluhana d0281bf
Verify PHPCs baseline action
kamleshluhana 0074502
Verify PHPCs baseline action
kamleshluhana ab45995
Verify PHPCs baseline action
kamleshluhana 410228e
Verify PHPCs baseline action
kamleshluhana cbbbd89
Verify PHPCs baseline action
kamleshluhana d48fceb
Verify PHPCs baseline action
kamleshluhana f06c872
Verify PHPCs baseline action
kamleshluhana 65bd618
Verify PHPCs baseline action
kamleshluhana 83f7927
Verify PHPCs baseline action
kamleshluhana eb4dad8
Verify PHPCs baseline action
kamleshluhana 71aa4a2
Verify PHPCs baseline action
kamleshluhana 245c1b9
Verify PHPCs baseline action
kamleshluhana 3e7afaa
Verify PHPCs baseline action
kamleshluhana 1d0382f
Verify PHPCs baseline action
kamleshluhana 3101aec
Verify PHPCs baseline action
kamleshluhana 90ea0b0
Modification based on Simon comments
kamleshluhana 06e7d58
Modification based on Simon comments
kamleshluhana e1b4fdd
Modification based on Simon comments
kamleshluhana 5647eb1
Modification based on Simon comments
kamleshluhana d466398
Modification based on Simon comments
kamleshluhana 6d03496
Merge remote-tracking branch 'origin/2.4-develop' into phpcs_baseline
kamleshluhana b223b5c
Testing of PHPCS
kamleshluhana 3e986e4
Fix workflow file issue
kamleshluhana b2326a9
Fix workflow file issue
kamleshluhana de2c0cf
Fix workflow file issue
kamleshluhana ba75deb
Fix workflow file issue
kamleshluhana 652ed72
Fix workflow file issue
kamleshluhana e1eb94c
Fix workflow file issue
kamleshluhana d1185be
Fix workflow file issue
kamleshluhana 5bbf172
Fix workflow file issue
kamleshluhana 122578f
Fix workflow file issue
kamleshluhana 252e3e4
Merge remote-tracking branch 'origin/2.4-develop' into phpcs_baseline
kamleshluhana bf87076
Testing PHPCS Baseline
kamleshluhana 29ca752
Testing PHPCS Baseline
kamleshluhana 629ccdb
Testing PHPCS Baseline
kamleshluhana 4f3bada
Testing PHPCS Baseline
kamleshluhana 5727ae9
Testing PHPCS Baseline
kamleshluhana 88aea1e
Testing PHPCS Baseline
kamleshluhana b23eed2
Testing PHPCS Baseline
kamleshluhana 2361dd9
Testing PHPCS Baseline
kamleshluhana c168718
Testing PHPCS Baseline
kamleshluhana e815525
Testing PHPCS Baseline
kamleshluhana 5379c0a
Testing PHPCS Baseline
kamleshluhana ccdae62
Testing PHPCS Baseline
kamleshluhana 2d8cbfb
Testing PHPCS Baseline
kamleshluhana 7775d06
Merge branch 'mage-os:2.4-develop' into phpcs_baseline
MeetKamal f90d914
Testing PHPCS Baseline
kamleshluhana 462a67d
Merge branch 'phpcs_baseline' of github.com:MeetKamal/mageos-magento2…
kamleshluhana 8915d55
Testing PHPCS Baseline
kamleshluhana 7e96a06
Testing PHPCS Baseline
kamleshluhana b5b4637
Testing PHPCS Baseline
kamleshluhana 202b303
Testing PHPCS Baseline
kamleshluhana 89b7334
Testing PHPCS Baseline
kamleshluhana 1085ff3
Testing PHPCS Baseline
kamleshluhana b9a4b7a
Testing PHPCS Baseline
kamleshluhana b19f4f9
Testing PHPCS Baseline
kamleshluhana f6ae066
Testing PHPCS Baseline
kamleshluhana 9a40ead
Testing PHPCS Baseline
kamleshluhana bcceae6
Testing PHPCS Baseline
kamleshluhana 89fa6b6
Testing PHPCS Baseline
kamleshluhana 9c8f8f7
Testing PHPCS Baseline
kamleshluhana 94f38ba
Testing PHPCS Baseline
kamleshluhana ca36e8d
Testing PHPCS Baseline
kamleshluhana 25d382d
Testing PHPCS Baseline
kamleshluhana 098ba23
Testing PHPCS Baseline
kamleshluhana ec48fe5
Testing PHPCS Baseline
kamleshluhana 5fc5d9a
Testing PHPCS Baseline
kamleshluhana 6d74bf9
Testing PHPCS Baseline
kamleshluhana 771293f
Testing PHPCS Baseline
kamleshluhana fe10004
Testing PHPCS Baseline
kamleshluhana aec686c
Testing PHPCS Baseline
kamleshluhana 3d177c1
Testing PHPCS Baseline
kamleshluhana 036fedb
Testing PHPCS Baseline
kamleshluhana 2f7a56e
Testing PHPCS Baseline
kamleshluhana fbc45da
Testing PHPCS Baseline
kamleshluhana a95414a
Testing PHPCS Baseline
kamleshluhana 16ee3a8
Testing PHPCS Baseline
kamleshluhana e4de9ce
Testing PHPCS Baseline
kamleshluhana 0b44940
Testing PHPCS Baseline
kamleshluhana be2594e
Testing PHPCS Baseline
kamleshluhana 6643af5
Testing PHPCS Baseline
kamleshluhana 00303c7
Testing PHPCS Baseline
kamleshluhana b28eecc
Testing PHPCS Baseline
kamleshluhana 84416fa
Add changes as requested by Simon
kamleshluhana 28cfc3c
Add changes as requested by Simon
kamleshluhana dceea69
Add changes as requested by Simon
kamleshluhana 4fda29d
Merge branch 'mage-os:2.4-develop' into phpcs_baseline
MeetKamal fa2e254
Apply changes as per Simon comments
kamleshluhana d617634
Apply changes as per Simon comments
kamleshluhana 7d2c9bd
Apply changes as per Simon comments
kamleshluhana fcef028
Apply changes as per Simon comments
kamleshluhana 07fe7cf
Apply changes as per Simon comments
kamleshluhana 687bb87
Apply changes as per Simon comments
kamleshluhana fdf9c21
Apply changes as per Simon comments
kamleshluhana 089841a
Apply changes as per Simon comments
kamleshluhana de14b7e
Apply changes as per Simon comments
kamleshluhana bd8df14
Apply changes as per Simon comments
kamleshluhana ee787da
Apply changes as per Simon comments
kamleshluhana 0a9e7e0
Apply changes as per Simon comments
kamleshluhana f5754e6
Apply changes as per Simon comments
kamleshluhana b1dc710
Apply changes as per Simon comments
kamleshluhana 196d27c
Apply changes as per Simon comments
kamleshluhana 19ae6a2
Apply changes as per Simon comments
kamleshluhana 6ca020b
Apply changes as per Simon comments
kamleshluhana 5a79ea2
Apply changes as per Simon comments
kamleshluhana 9a1869d
Apply changes as per Simon comments
kamleshluhana 23ad922
Apply changes as per Simon comments
kamleshluhana 2c28d81
Apply changes as per Simon comments
kamleshluhana 547db2e
Apply changes as per Simon comments
kamleshluhana bad8cf7
Apply changes as per Simon comments
kamleshluhana 16d7f0d
Apply changes as per Simon comments
kamleshluhana 66ca8fe
Apply changes as per Simon comments
kamleshluhana 2e663f4
Apply changes as per Simon comments
kamleshluhana 659310a
Apply changes as per Simon comments
kamleshluhana 3cc58b9
Apply changes as per Simon comments
kamleshluhana d7eaefb
Apply changes as per Simon comments
kamleshluhana da31665
Apply changes as per Simon comments
kamleshluhana 0d3b0fd
Apply changes as per Simon comments
kamleshluhana 56f953e
Apply changes as per Simon comments
kamleshluhana 1b3e40f
Apply changes as per Simon comments
kamleshluhana 057ed9d
Reverback code base
kamleshluhana 65d8aec
Testing of baseline file
kamleshluhana 23e0176
Testing of baseline file
kamleshluhana 82c5e3a
Testing of baseline file
kamleshluhana 4f57aab
Testing of baseline file
kamleshluhana 6fb151e
Testing of baseline file
kamleshluhana 372f2dc
Testing of baseline file
kamleshluhana 5fc1ba8
Testing of baseline file
kamleshluhana b62fa5d
Fix PHPCS Baseline issues
kamleshluhana c03b43b
Fix PHPCS Baseline issues
kamleshluhana 330a4dd
Fix PHPCS Baseline issues
kamleshluhana a704d0a
Fix PHPCS Baseline issues
kamleshluhana 73e7480
Fix PHPCS Baseline issues
kamleshluhana 34a7f8e
Fix PHPCS Baseline issues
kamleshluhana 27a34c0
Fix PHPCS Baseline issues
kamleshluhana 1986510
Fix PHPCS Baseline issues
kamleshluhana a541cb5
Fix PHPCS Baseline issues
kamleshluhana ab34134
Fix PHPCS Baseline issues
kamleshluhana 9e61866
Fix PHPCS Baseline issues
kamleshluhana 803a6b0
Fix PHPCS Baseline issues
kamleshluhana da47eed
Fix PHPCS Baseline issues
kamleshluhana 913c048
Fix PHPCS Baseline issues
kamleshluhana 7076c43
Fix PHPCS Baseline issues
kamleshluhana f39bcb5
Fix PHPCS Baseline issues
kamleshluhana ff00519
Fix PHPCS Baseline issues
kamleshluhana 595d9a9
Fix PHPCS Baseline issues
kamleshluhana d2e9841
Fix PHPCS Baseline issues
kamleshluhana 1aea775
Fix PHPCS Baseline issues
kamleshluhana 25d3c8e
Fix PHPCS Baseline issues
kamleshluhana 923c0da
Fix PHPCS Baseline issues
kamleshluhana 71798a7
Fix PHPCS Baseline issues
kamleshluhana 8f121dc
Fix PHPCS Baseline issues
kamleshluhana d2c7600
Fix PHPCS Baseline issues
kamleshluhana 7e55297
Fix PHPCS Baseline issues
kamleshluhana 1863816
Fix PHPCS Baseline issues
kamleshluhana 689b49b
Fix PHPCS Baseline issues
kamleshluhana b473b56
Fix PHPCS Baseline issues
kamleshluhana 721a886
Fix PHPCS Baseline issues
kamleshluhana cb94e2c
Fix PHPCS Baseline issues
kamleshluhana defc916
Fix PHPCS Baseline issues
kamleshluhana 5ebcac4
Fix PHPCS Baseline issues
kamleshluhana 1694e85
Fix PHPCS Baseline issues
kamleshluhana bb45dad
Fix PHPCS Baseline issues
kamleshluhana fcef7b8
Fix PHPCS Baseline issues
kamleshluhana 4d7e154
Fix PHPCS Baseline issues
kamleshluhana bf422d2
Fix PHPCS Baseline issues
kamleshluhana b5129c7
Fix PHPCS Baseline issues
kamleshluhana 3ee8aae
Fix PHPCS Baseline issues
kamleshluhana e7088c6
Fix PHPCS Baseline issues
kamleshluhana c55851d
Fix PHPCS Baseline issues
kamleshluhana 88459f5
Fix PHPCS Baseline issues
kamleshluhana be45e8b
Fix PHPCS Baseline issues
kamleshluhana 82d6c60
Fix PHPCS Baseline issues
kamleshluhana edee662
Fix PHPCS Baseline issues
kamleshluhana 800224b
Fix PHPCS Baseline issues
kamleshluhana 52a69fc
Fix PHPCS Baseline issues
kamleshluhana 925110e
Fix PHPCS Baseline issues
kamleshluhana af55fda
Fix PHPCS Baseline issues
kamleshluhana 54fbefe
Fix coding standards
kamleshluhana de6613c
Fix PHPCS issue - inputs var
kamleshluhana 793be69
Fix PHPCS issue - inputs var
kamleshluhana f74ed62
Fix PHPCS issue - inputs var
kamleshluhana 9a93d20
Fix PHPCS issue - inputs var
kamleshluhana 18df81d
Fix PHPCS issue - inputs var
kamleshluhana 2b37f36
Fix PHPCS issue - inputs var
kamleshluhana 638c65c
Review PHPCS issue
kamleshluhana 4613b00
Review PHPCS issue
kamleshluhana 0d55095
Review PHPCS issue
kamleshluhana 4a40882
Fix input vars with new folder
kamleshluhana 3164e00
Fix input vars with new folder
kamleshluhana 59df2a8
Fix input vars with new folder
kamleshluhana 45c046d
Fix input vars with new folder
kamleshluhana 95f9037
Fix input vars with new folder
kamleshluhana c976415
Fix input vars with new folder
kamleshluhana 17ca6b0
Fix input vars with new folder
kamleshluhana 2d2ff1d
Fix input vars with new folder
kamleshluhana 4dd635e
Fix input vars with new folder
kamleshluhana 42667b4
Fix input vars with new folder
kamleshluhana f1265b3
Fix input vars with new folder
kamleshluhana 39bf679
Fix input vars with new folder
kamleshluhana 4b8273b
Review PHPCS issue - inputs var
kamleshluhana e2852c3
Merge branch 'mage-os:2.4-develop' into phpcs_baseline
MeetKamal 765bec5
Modify codebase for coding standard baseline
kamleshluhana 7348961
Modify codebase for coding standard baseline
kamleshluhana 46c58ff
Modify codebase for coding standard baseline
kamleshluhana 31e4688
Modify codebase for coding standard baseline
kamleshluhana 9c8126c
Modify codebase for coding standard baseline
kamleshluhana 2831ee8
Modify codebase for coding standard baseline
kamleshluhana 2ddab8b
Modify codebase for coding standard baseline
kamleshluhana 634d55f
Modify codebase for coding standard baseline
kamleshluhana 63d4033
Modify codebase for coding standard baseline
kamleshluhana 900a6e6
Modify codebase for coding standard baseline
kamleshluhana 32fbd31
Merge branch 'mage-os:2.4-develop' into phpcs_baseline
MeetKamal 92be37b
Fix basline changes as per Simon
kamleshluhana 25909a8
Fix basline changes as per Simon
kamleshluhana 3349874
added validation for xml files and html
kamleshluhana ab59c8b
added validation for xml files and html
kamleshluhana 95fdfb5
added validation for xml files and html
kamleshluhana f93d01a
Merge branch 'mage-os:2.4-develop' into phpcs_baseline
MeetKamal acd2a17
Apply new github action for coding standard validation
kamleshluhana d358b6d
Validate coding standard based on new github action file
kamleshluhana File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Magento 2 Coding Standard Action | ||
|
||
A Github Action that runs the Magento Coding Standard. | ||
|
||
## Inputs | ||
|
||
See the [action.yml](./action.yml) | ||
|
||
## Usage | ||
|
||
```yml | ||
name: Coding Standard | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
coding-standard: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: graycoreio/github-actions-magento2/coding-standard@main | ||
with: | ||
version: 25 # Optional, will use the latest if omitted. | ||
path: app/code # Optional, will be used when event is not a pull request. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
name: "M2 Coding Standard" | ||
author: "Mage-OS" | ||
description: "A Github Action that runs the Magento Coding Standard." | ||
|
||
inputs: | ||
php_version: | ||
type: string | ||
required: true | ||
default: "8.1" | ||
description: "PHP version used to do the coding standard check." | ||
|
||
composer_version: | ||
type: string | ||
required: true | ||
default: "2" | ||
description: "The version of composer to use." | ||
|
||
path: | ||
type: string | ||
required: true | ||
default: 'app/code' | ||
description: "The directory (relative to the project root) in which the coding standard will be checked. Used when the event is not a pull request." | ||
|
||
version: | ||
type: string | ||
required: false | ||
default: "31" | ||
description: "The version of the coding standard to use. If not provided, will use the latest version." | ||
|
||
severity: | ||
type: string | ||
required: false | ||
default: "8" | ||
description: "The minimum severity required to display an error or warning (default: 5)" | ||
|
||
warning_severity: | ||
type: string | ||
required: false | ||
default: "8" | ||
description: "The minimum severity required to display a warning" | ||
|
||
error_severity: | ||
type: string | ||
required: false | ||
default: "8" | ||
description: "The minimum severity required to display an error" | ||
|
||
baseline_version: | ||
type: string | ||
required: false | ||
default: "1.1.2" | ||
description: "version of phpcs baseline" | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Checkout Project | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set PHP Version | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ inputs.php_version }} | ||
tools: composer:v${{ inputs.composer_version }} | ||
coverage: none | ||
|
||
- name: Install Coding Standard && Codesniffer baseline | ||
shell: bash | ||
run: | | ||
git config --global advice.detachedHead false | ||
composer require "magento/magento-coding-standard: ${{ github.event.inputs.version || '*' }}" -W | ||
composer config --no-plugins allow-plugins.digitalrevolution/php-codesniffer-baseline true | ||
composer require --dev "digitalrevolution/php-codesniffer-baseline: ${{ github.event.inputs.baseline_version || '*' }}" | ||
|
||
- name: Register Coding Standard | ||
shell: bash | ||
run: vendor/bin/phpcs --config-set installed_paths ${{ github.workspace }}/vendor/magento/magento-coding-standard,${{ github.workspace }}/vendor/phpcompatibility/php-compatibility | ||
|
||
- name: Get all changed files | ||
uses: tj-actions/changed-files@v37 | ||
with: | ||
write_output_files: true | ||
output_dir: ${{ github.workspace }} | ||
separator: " " | ||
|
||
- name: Verify the contents of the modified_files.txt file | ||
shell: bash | ||
run: | | ||
sed "s/ /\n/g" ${{ github.workspace }}/modified_files.txt > ${{ github.workspace }}/newline_file.txt | ||
grep -iE "\.php|\.phtml|\.html|\.xml" ${{ github.workspace }}/newline_file.txt > ${{ github.workspace }}/phpcs_files.txt | ||
|
||
- name: Checkout - Before Merge | ||
shell: bash | ||
run: | | ||
if ${{ github.event_name == 'pull_request' }}; then | ||
git checkout ${{ github.event.pull_request.base.ref }} | ||
else | ||
git checkout ${{ github.event.before }} | ||
fi | ||
|
||
- name: Filter php files and execute phpcs - Before Merge | ||
shell: bash | ||
run: | | ||
php vendor/bin/phpcs --standard=Magento2 \ | ||
$([ -n "${{ inputs.severity }}" ] && echo "--severity=${{ inputs.severity }}") \ | ||
$([ -n "${{ inputs.warning_severity }}" ] && echo "--warning-severity=${{ inputs.warning_severity }}") \ | ||
$([ -n "${{ inputs.error_severity }}" ] && echo "--error-severity=${{ inputs.error_severity }}") \ | ||
--report=\\DR\\CodeSnifferBaseline\\Reports\\Baseline --report-file=${{ github.workspace }}/phpcs.baseline.xml --file-list=${{ github.workspace }}/phpcs_files.txt || /bin/true | ||
|
||
- name: Checkout after Merge and execute phpcs | ||
shell: bash | ||
run: | | ||
if ${{ github.event_name == 'pull_request' }}; then | ||
git checkout ${{ github.event.pull_request.head.ref }} | ||
else | ||
git checkout ${{ github.event.after }} | ||
fi | ||
php vendor/bin/phpcs --standard=Magento2 \ | ||
$([ -n "${{ inputs.severity }}" ] && echo "--severity=${{ inputs.severity }}") \ | ||
$([ -n "${{ inputs.warning_severity }}" ] && echo "--warning-severity=${{ inputs.warning_severity }}") \ | ||
$([ -n "${{ inputs.error_severity }}" ] && echo "--error-severity=${{ inputs.error_severity }}") \ | ||
--file-list=${{ github.workspace }}/phpcs_files.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,52 @@ | ||
name: Coding Standard | ||
name: M2 Coding Testing | ||
|
||
on: | ||
push: | ||
branches: [ 2.4-develop, develop, phpcs_baseline ] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think in the end, this only needs to include There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, for testing purpose I added another branches to review |
||
pull_request: | ||
branches: | ||
- 2.4-develop | ||
branches: [ 2.4-develop, develop, phpcs_baseline ] | ||
workflow_call: | ||
inputs: | ||
php_version: | ||
type: string | ||
required: true | ||
default: "8.1" | ||
description: "PHP version used to do the coding standard check." | ||
|
||
composer_version: | ||
type: string | ||
required: true | ||
default: "2" | ||
description: "The version of composer to use." | ||
|
||
path: | ||
type: string | ||
required: true | ||
default: 'app/code' | ||
description: "The directory (relative to the project root) in which the coding standard will be checked. Used when the event is not a pull request." | ||
|
||
version: | ||
type: string | ||
required: false | ||
description: "The version of the coding standard to use. If not provided, will use the latest version." | ||
|
||
severity: | ||
type: string | ||
required: false | ||
default: "8" | ||
description: "The minimum severity required to display an error or warning (default: 5)" | ||
|
||
warning_severity: | ||
type: string | ||
required: false | ||
default: "8" | ||
description: "The minimum severity required to display a warning" | ||
|
||
error_severity: | ||
type: string | ||
required: false | ||
default: "8" | ||
description: "The minimum severity required to display an error" | ||
|
||
permissions: | ||
contents: read | ||
|
@@ -12,5 +55,13 @@ jobs: | |
coding-standard: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Run Coding Standard | ||
uses: mage-os/github-actions/coding-standard@main | ||
- uses: actions/checkout@v1 | ||
- uses: mage-os/github-actions/coding-standard-baseline@main | ||
with: | ||
php_version: "8.1" # Optional, will be used for Php version | ||
composer_version: "2" | ||
version: "31" # Optional, will use the latest if omitted. | ||
severity: "8" # Optional, will use phpcs default of 5 if not specified. | ||
warning_severity: "4" # Optional, will use warning severity value if not specified. | ||
error_severity: "7" # Optional, will use error severity value if not specified. | ||
baseline_version: "1.1.2" # Optional, will use for php codesniffer baseline version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...ode/Magento/Customer/Model/App/FrontController/DeleteCookieWhenCustomerNotExistPlugin.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Customer\Model\App\FrontController; | ||
|
||
use Magento\Framework\App\Response\Http as ResponseHttp; | ||
use Magento\Customer\Model\Session; | ||
|
||
/** | ||
* Plugin for delete the cookie when the customer is not exist. | ||
* | ||
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse) | ||
*/ | ||
class DeleteCookieWhenCustomerNotExistPlugin | ||
{ | ||
/** | ||
* @var ResponseHttp | ||
*/ | ||
private $responseHttp; | ||
|
||
/** | ||
* @var Session | ||
*/ | ||
private $session; | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param ResponseHttp $responseHttp | ||
* @param Session $session | ||
*/ | ||
public function __construct( | ||
ResponseHttp $responseHttp, | ||
Session $session | ||
) { | ||
$this->responseHttp = $responseHttp; | ||
$this->session = $session; | ||
} | ||
|
||
/** | ||
* Delete the cookie when the customer is not exist before dispatch the front controller. | ||
* | ||
* @return void | ||
*/ | ||
public function beforeDispatch(): void | ||
{ | ||
if (!$this->session->getCustomerId()) { | ||
$this->responseHttp->sendVary(); | ||
} | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
...stomer/Test/Unit/Model/App/FrontController/DeleteCookieWhenCustomerNotExistPluginTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Customer\Test\Unit\Model\App\FrontController; | ||
|
||
use Magento\Customer\Model\App\FrontController\DeleteCookieWhenCustomerNotExistPlugin; | ||
use Magento\Framework\App\Response\Http as ResponseHttp; | ||
use Magento\Customer\Model\Session; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Tests \Magento\Customer\Model\App\FrontController\DeleteCookieWhenCustomerNotExistPluginTest. | ||
*/ | ||
class DeleteCookieWhenCustomerNotExistPluginTest extends TestCase | ||
{ | ||
/** | ||
* @var DeleteCookieWhenCustomerNotExistPlugin | ||
*/ | ||
protected DeleteCookieWhenCustomerNotExistPlugin $plugin; | ||
|
||
/** | ||
* @var ResponseHttp|MockObject | ||
*/ | ||
protected ResponseHttp|MockObject $responseHttpMock; | ||
|
||
/** | ||
* @var Session|MockObject | ||
*/ | ||
protected MockObject|Session $customerSessionMock; | ||
|
||
/** | ||
* Set up | ||
*/ | ||
protected function setUp(): void | ||
{ | ||
$this->customerSessionMock = $this->createMock(Session::class); | ||
$this->responseHttpMock = $this->createMock(ResponseHttp::class); | ||
$this->plugin = new DeleteCookieWhenCustomerNotExistPlugin( | ||
$this->responseHttpMock, | ||
$this->customerSessionMock | ||
); | ||
} | ||
|
||
public function testBeforeDispatch() | ||
{ | ||
$this->customerSessionMock->expects($this->once()) | ||
->method('getCustomerId') | ||
->willReturn(0); | ||
$this->plugin->beforeDispatch(); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think "Coding Standard" or "M2 Coding Standard" is the better choice here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bump :)