Skip to content
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

Update code style #56

Closed
wants to merge 330 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
330 commits
Select commit Hold shift + click to select a range
4c7b17f
Update advanced edit toggle arrow
joran29 Sep 19, 2024
1ef8920
Add custom_data validation in FacebookCapiEvent clas
Luka130899 Sep 20, 2024
b759523
Update nonce error message in send_capi_event endpoint
Luka130899 Sep 20, 2024
6de4c6b
Update js ajax request error logic in sendTestEvent function
Luka130899 Sep 20, 2024
5173d7e
Remove not used data from row element in events-log table
Luka130899 Sep 20, 2024
a60d047
Update testEventName value for advanced payload to include all event …
Luka130899 Sep 20, 2024
95a1154
Do not send custom_data data when an advanced payload is being sent
Luka130899 Sep 20, 2024
57e0125
Update event log error section style/behavior
joran29 Sep 20, 2024
9748bec
Move event log error message in a new td
joran29 Sep 20, 2024
ac01eae
Update event log error section style/behavior
joran29 Sep 20, 2024
4979494
Update show error section style in event log block
joran29 Sep 20, 2024
54adff2
Minor style update for show error section in event log block
joran29 Sep 20, 2024
43c70a7
Minor style update for show error section in event log block
joran29 Sep 20, 2024
9e326f8
Update check for required advanced payload
Luka130899 Sep 20, 2024
677593c
Update test event table style
joran29 Sep 20, 2024
0dc0224
Use correct test_event_code when populating advanced payload field
Luka130899 Sep 20, 2024
643c1d2
Update populate advanced event with a default event code if one not p…
joran29 Sep 20, 2024
250f62b
Add event hints section to events block when no events logged
joran29 Sep 23, 2024
6d0bacd
Minor style update for event hints
joran29 Sep 23, 2024
b6577c9
Minor style update for event log block td
joran29 Sep 23, 2024
a9f0084
Update error pill colors
joran29 Sep 23, 2024
9836291
Update test/event hints style
joran29 Sep 23, 2024
020d8b2
Update test/event hints icons with symbols
joran29 Sep 23, 2024
e768593
Minor style update for test/event hints symbols
joran29 Sep 23, 2024
0caf69f
Update events manager section responsiveness
joran29 Sep 23, 2024
a2b5942
Update logic for get_invalid_event_custom_data method in FacebookCapi…
Luka130899 Oct 3, 2024
a6ac00c
Validate custom_data before creating default events in send_capi_even…
Luka130899 Oct 3, 2024
170895b
Add REQUIRED_EVENT_DATA to FacebookCapiEvent class
Luka130899 Oct 3, 2024
904b8bb
Add validate_payload and validate_json methods to FacebookCapiEvent c…
Luka130899 Oct 3, 2024
a7d215e
Use payload validation methods before sending custom payload events i…
Luka130899 Oct 3, 2024
8777458
Add expected type for required_event_data in FacebookCapiEvent class
Luka130899 Oct 4, 2024
24468f7
Add type validation for required_event_data in FacebookCapiEvent class
Luka130899 Oct 4, 2024
0b46d09
Remove expected type for required_event_data from FacebookCapiEvent c…
Luka130899 Oct 7, 2024
0865abe
Add VALID_EVENT_ATTRIBUTES_TYPE to FacebookCapiEvent class
Luka130899 Oct 7, 2024
dfd6eee
Update event attributes type validation logic in FacebookCapiEvent class
Luka130899 Oct 7, 2024
807bca7
Check if event_name is present before creating default event in send_…
Luka130899 Oct 8, 2024
dc5c0a1
Set event_name to null if not provided in POST request
Luka130899 Oct 8, 2024
833a8bc
Update event log block table style
joran29 Oct 8, 2024
6ac49f2
Update events hints note behavior on first test event submit
joran29 Oct 8, 2024
be11d8d
Fix typo for event hints class
joran29 Oct 8, 2024
272aa87
Update event hints close icon html symbol
joran29 Oct 8, 2024
47f3d4e
Minor style update for event hints close icon
joran29 Oct 8, 2024
19aefec
Update event hints close icon html symbol
joran29 Oct 8, 2024
c56b19c
Minor style update for event hints close icon
joran29 Oct 8, 2024
31f75eb
Minor style update for event hints close icon
joran29 Oct 8, 2024
0b00ada
Update validate_json method in FacebookCapiEvent class
Luka130899 Oct 8, 2024
03f33e3
Minor style adjustment for text form inputs
joran29 Oct 8, 2024
ced08e0
Update event log block table head style
joran29 Oct 8, 2024
804e85f
Add hideEventsManagerSection function to FBEFlowContainer React class
Luka130899 Oct 8, 2024
f712bba
Add showEventsManagerSection function to FBEFlowContainer React class
Luka130899 Oct 8, 2024
063fb19
Add id to pixel-id input field on admin settings page
Luka130899 Oct 8, 2024
44463b5
Add style for hidden class on events-manager-wrapper element
Luka130899 Oct 8, 2024
d3689d1
Hide CAPI section from admin settings when user is not connected to FB
Luka130899 Oct 8, 2024
b62bda3
Fix issue with empty custom_data POST param in send_capi_event method
Luka130899 Oct 9, 2024
5586315
Send user_data when sending AJAX request to send_capi_event endpoint
Luka130899 Oct 9, 2024
aa23170
Add user_data to default events payload if present in POST params
Luka130899 Oct 9, 2024
fc36690
Move js from FacebookWordpressSettingsPage class into separate js file
Luka130899 Oct 11, 2024
4608674
Remove inline style from FacebookWordpressSettingsPage class
Luka130899 Oct 14, 2024
4edfd5c
Move js from FacebookWordpressEasyDigitalDownloads class into separat…
Luka130899 Oct 15, 2024
a459a1e
Update codestyle to match wordpress
nikolap994 Oct 24, 2024
0668056
Fix codestyle for class-facebookforwordpress
nikolap994 Oct 24, 2024
3f0b6a2
Fix task baseTask code style
nikolap994 Oct 24, 2024
d808428
Update codestyle for FacebookWordpressAddVersionNumberTask class
nikolap994 Oct 24, 2024
6df19ff
Fix codestyle for FacebookWordpressGetVersionNumberTask
nikolap994 Oct 24, 2024
ea99116
Update code style for EDDUtils and fix function names after renaming
nikolap994 Oct 24, 2024
76f3703
Update code style for FacebookWordpressCalderaForm
nikolap994 Oct 24, 2024
6fecee4
Update code style for FacebookWordpressContactForm7
nikolap994 Oct 24, 2024
e5526a4
Add copyright block for updated files
nikolap994 Oct 25, 2024
cd8bc9c
Update codestyle
nikolap994 Oct 25, 2024
8a96c4d
Update code style for FacebookWordpressEasyDigitalDownloads
nikolap994 Oct 25, 2024
57ada21
Update codestyle for FacebookWordpressFormidableForm class
nikolap994 Oct 25, 2024
4569146
Fix loose check for FacebookWordpressFormidableForm class
nikolap994 Oct 25, 2024
dc50d72
Fix codestyle for FacebookWordpressIntegrationBase
nikolap994 Oct 25, 2024
4324e48
Update code style for FacebookWordpressMailchimpForWp
nikolap994 Oct 25, 2024
847d8ab
Update code style for FacebookWordpressNinjaForms
nikolap994 Oct 25, 2024
0043e45
Update code style for AAMFieldsExtractor
Luka130899 Oct 25, 2024
81c96b7
Fix code style for FacebookWordpressWooCommerce
nikolap994 Oct 25, 2024
66d53e3
Fix code style for FacebookWordpressWPECommerce class
nikolap994 Oct 25, 2024
a7d523f
Update code style for AAMSettingsFields
Luka130899 Oct 25, 2024
ab772a6
Update code style for EventIdGenerator
Luka130899 Oct 25, 2024
17a22c7
Upadate code style for FacebookWordpressWPForms
nikolap994 Oct 25, 2024
7c07fa6
Update code style for FacebookCapiEvent
Luka130899 Oct 25, 2024
1e6d6c4
Fix loose comparions check
nikolap994 Oct 25, 2024
3940525
Update IntegrationUtils code style with function rename
nikolap994 Oct 25, 2024
89e381d
Update code style for FileNameTest
nikolap994 Oct 25, 2024
65bdb3d
Update code style for FacebookWordpressTestBase
nikolap994 Oct 25, 2024
100de65
Update code style for FacebookPixel
Luka130899 Oct 25, 2024
9ebf601
Rename method used in testGetPixelViewContentCode function in Faceboo…
Luka130899 Oct 25, 2024
84ae6e3
Update code style for FacebookPluginConfig
Luka130899 Oct 25, 2024
6dcefec
Update code style for FacebookPluginUtils
Luka130899 Oct 25, 2024
5107820
Update code style for FacebookServerSideEvent
Luka130899 Oct 25, 2024
da53728
Update bootstrap code style
nikolap994 Oct 25, 2024
6ec221a
Remove override
nikolap994 Oct 25, 2024
776ffb3
Update code style for MockContactForm7
nikolap994 Oct 25, 2024
0c64a12
Update code style for MockContactForm7Tag
nikolap994 Oct 25, 2024
332d5e4
Update code style for MockFormidableFormEntryValues
nikolap994 Oct 25, 2024
98edbd2
Update code style for FacebookWordpressOpenBridge
Luka130899 Oct 25, 2024
2c81529
Update code style for MockFormidableFormField
nikolap994 Oct 25, 2024
bf60341
Update code style for MockFormidableFormFieldValue
nikolap994 Oct 25, 2024
516a9fe
Update code style for MockGravityFormField
nikolap994 Oct 25, 2024
774fdce
Fix code style for Mock WC
nikolap994 Oct 25, 2024
0c218c5
Update code style for MockWCCart
nikolap994 Oct 25, 2024
f7eb9b6
Update code style for MockWCOrder
nikolap994 Oct 25, 2024
ecde350
Update code style for MockWCOrderItem
nikolap994 Oct 25, 2024
9393263
Update code style for MockWCProduct
nikolap994 Oct 25, 2024
246cdc7
Update code style FacebookWordpressCalderaFormTest
nikolap994 Oct 25, 2024
be40953
Update code style for FacebookWordpressContactForm7Test
nikolap994 Oct 25, 2024
5e3b8c2
Update code style for FacebookWordpressEasyDigitalDownloadsTest
nikolap994 Oct 25, 2024
3a3215b
Update code style for FacebookWordpressFormidableFormTest
nikolap994 Oct 25, 2024
984ebb2
Update code style for FacebookWordpressMailchimpForWpTest
nikolap994 Oct 25, 2024
cb6693a
Update code style for FacebookWordpressNinjaFormsTest
nikolap994 Oct 25, 2024
f0e0f12
Update code style for FacebookWordpressWooCommerceTest
nikolap994 Oct 25, 2024
2c416e4
Update code style for FacebookWordpressOptions
Luka130899 Oct 25, 2024
fa49507
Update code style for FacebookWordpressWPECommerceTest
nikolap994 Oct 25, 2024
b7eec44
Update code style for FacebookWordpressWPFormsTest
nikolap994 Oct 25, 2024
402023f
Update code style for AAMFieldsExtractorTest
nikolap994 Oct 25, 2024
e0a81ac
Update code style for FacebookWordpressPixelInjection
Luka130899 Oct 25, 2024
a5f5534
Update code style for EventIdGeneratorTest
nikolap994 Oct 25, 2024
f9bcab9
Update code style for FacebookPixelTest
nikolap994 Oct 25, 2024
b0939f7
Update code style for FacebookPluginUtilsTest
nikolap994 Oct 25, 2024
168f664
Update code style for FacebookServerSideEventTest
nikolap994 Oct 25, 2024
d543c74
Update code style for FacebookWordPressOpenBridgeTest
nikolap994 Oct 25, 2024
44a287e
Update code style for FacebookWordpressOptionsTest
nikolap994 Oct 25, 2024
86aeedb
Change func param to more descriptive name
nikolap994 Oct 25, 2024
d9c7aaa
Update code style for FacebookWordpressPixelInjectionTest
nikolap994 Oct 25, 2024
b59b597
Update code style for FacebookWordPressSettingsPageTest
nikolap994 Oct 25, 2024
b3a4435
Update code style for FacebookWordpressSettingsRecorderTest
nikolap994 Oct 25, 2024
2730460
Fix issue with method name on FacebookWordpressPixelInjection
Luka130899 Oct 25, 2024
fa55060
Update code style for PixelRendererTest
nikolap994 Oct 25, 2024
f602654
Fix code style for ServerEventFactoryTest
nikolap994 Oct 25, 2024
f7ff59f
Update code style for uninstall script
nikolap994 Oct 25, 2024
4323a56
Fix loose check for event number
nikolap994 Oct 25, 2024
ed7b14f
Fix code style for EventIdGenerator
nikolap994 Oct 25, 2024
9b3381d
Update code style for AAMSettingsFields
nikolap994 Oct 25, 2024
bc2e5c2
Update code style for AAMFieldsExtractor
nikolap994 Oct 25, 2024
b45d9c1
Update code style for FacebookCapiEvent
nikolap994 Oct 25, 2024
124701c
Update code style for FacebookPixel
nikolap994 Oct 25, 2024
ff194db
Update code style for FacebookPluginConfig
nikolap994 Oct 25, 2024
b3efae5
Update code style for FacebookPluginUtils
nikolap994 Oct 25, 2024
112f661
Update code style for FacebookServerSideEvent
nikolap994 Oct 25, 2024
6aa0885
Update code style for FacebookWordpressOpenBridge
nikolap994 Oct 25, 2024
1451efd
Update code style for FacebookWordpressSettingsPage
Luka130899 Oct 25, 2024
28e7f91
Update code style for FacebookWordpressOptions
nikolap994 Oct 25, 2024
2661359
Update code style for FacebookWordpressPixelInjection
nikolap994 Oct 25, 2024
fbb171a
Update code style for FacebookWordpressSettingsPage
nikolap994 Oct 25, 2024
37e6da9
Update code style for FacebookWordpressSettingsRecorder
Luka130899 Oct 25, 2024
7b5b1c0
Update code style for PixelRenderer
nikolap994 Oct 28, 2024
4f3d53e
Clean up phpcs:ignore from bootstrap
nikolap994 Oct 28, 2024
26406d0
Cleanup phpcs ignore from uninstall script
nikolap994 Oct 28, 2024
4aa982d
Update code style for ServerEventAsyncTask
Luka130899 Oct 28, 2024
21fecc7
Update code style for ServerEventFactory
Luka130899 Oct 28, 2024
283197a
Add proper check for admin role
nikolap994 Oct 28, 2024
35d9775
Fix sanitization for class-facebookforwordpress
nikolap994 Oct 28, 2024
22abdb3
Add ignore for Tasks folder
nikolap994 Oct 28, 2024
26f75e5
Correct file names to match wordpress code style
nikolap994 Oct 28, 2024
b87dc89
Fix file names for all mock classes
nikolap994 Oct 28, 2024
3a03d64
Fix file names for integration
nikolap994 Oct 28, 2024
24c2b23
Fix file names to match wordpress code style for core AAM Fields cla…
Luka130899 Oct 28, 2024
563eea9
Fix file names for __tests__ core
nikolap994 Oct 28, 2024
a335917
Fix file names for rest of tests scripts
nikolap994 Oct 28, 2024
9bd64a3
Fix file names to match wordpress code style for core FacebookWordpr…
Luka130899 Oct 28, 2024
c8c222b
Fix file names to match wordpress code style for core Facebook classes
Luka130899 Oct 28, 2024
0890f95
Add ignore for __tests__ and remove unused wp code
nikolap994 Oct 28, 2024
7529a4a
Fix file names to match wordpress code style for core ServerEvent cla…
Luka130899 Oct 28, 2024
709ec56
Fix file name to match wordpress code style for core EventIdGenerator…
Luka130899 Oct 28, 2024
991c5f8
Fix file name to match wordpress code style for core PixelRenderer class
Luka130899 Oct 28, 2024
bbd2f03
Fix file name to match wordpress code style for integration EDDUtils …
Luka130899 Oct 28, 2024
932d3cc
Fix file names to match wordpress code style for integration Facebook…
Luka130899 Oct 28, 2024
d8362f5
Fix integration EDDUtils class file name
Luka130899 Oct 28, 2024
404452e
Fix file name to match wordpress code style for integration Integrati…
Luka130899 Oct 28, 2024
21473d5
Remove redundant comments
nikolap994 Oct 28, 2024
0bdeb56
Fix sanitization for class-facebookcapievent
Luka130899 Oct 28, 2024
cf5d016
Fix sanitization for class-facebookwordpressopenbridge
Luka130899 Oct 28, 2024
7dbee6c
Fix proper check for admin permissions
nikolap994 Oct 28, 2024
81703c1
Fix sanitization for class-servereventasynctask
Luka130899 Oct 28, 2024
2bc7ee8
Remove fixed ignore
nikolap994 Oct 28, 2024
042bfac
Fix sanitization for class-facebookwordpresscontactform7
Luka130899 Oct 28, 2024
5085f3c
Fix sanitization for class-facebookwordpresscalderaform
Luka130899 Oct 28, 2024
348945d
Fix sanitization for class-facebookwordpresseasydigitaldownloads
Luka130899 Oct 28, 2024
da5c44c
Fix sanitization for class-servereventfactory
Luka130899 Oct 28, 2024
18efd65
Fix escaping for class-facebookwordpresssettingspage
Luka130899 Oct 28, 2024
6e627aa
Fix escaping for class-facebookwordpresscontactform7
Luka130899 Oct 28, 2024
784c444
Fix escaping for class-facebookwordpresswpforms
Luka130899 Oct 28, 2024
b172505
Revert "Fix escaping for class-facebookwordpresswpforms"
Luka130899 Oct 28, 2024
a62b8de
Revert "Fix escaping for class-facebookwordpresscontactform7"
Luka130899 Oct 28, 2024
b2dcd04
Revert "Fix escaping for class-facebookwordpresssettingspage"
Luka130899 Oct 28, 2024
2d7746e
Fix translations issue
nikolap994 Oct 28, 2024
99342fd
Fix method names in FacebookWordpressIntegrationBase class
Luka130899 Oct 28, 2024
5c2a220
Fix format for phpcs ignore
nikolap994 Oct 28, 2024
10a37a0
Fix inject pixel function name in README and CONTRIBUTING
Luka130899 Oct 28, 2024
4ad9a16
Fix invalid names after file renaming
nikolap994 Oct 29, 2024
2c0b036
Add required composer.phar for builds
nikolap994 Oct 29, 2024
268794d
Revert escapes and file names for __tests__
nikolap994 Oct 31, 2024
21b7a25
Revert sanitizaion of required fields
nikolap994 Oct 31, 2024
21e3b35
Change from wp function to default php function in tests
nikolap994 Oct 31, 2024
0263887
Revert sanitization in ServerEventFactory
Luka130899 Nov 1, 2024
1f48652
Fix 'isInternalUser' method name in FacebookWordpressTestBase
Luka130899 Nov 1, 2024
7a388a4
Fix class comment for tests
Luka130899 Nov 1, 2024
cdc249b
Fix 'registerUserInfo' method name in FacebookWordpressOptions
Luka130899 Nov 1, 2024
1de05f9
Fix issue with 'testCanSetVersionInfoAndGetAgentString' method in Fac…
Luka130899 Nov 1, 2024
0a278a7
Revert global wp_version in FacebookWordpressTestBase
Luka130899 Nov 1, 2024
6d616b6
Revert code block in 'testViewContentWithoutAdmin' method in Facebook…
Luka130899 Nov 1, 2024
57cde94
Extend tests with built in wp functions
nikolap994 Nov 1, 2024
1cf27bc
Fix 'fbc' and 'fbp' errors on ServerEventFactoryTest
Luka130899 Nov 1, 2024
2b72237
Add missing helper functions for tests
nikolap994 Nov 4, 2024
ed7519a
Add proper error handling
nikolap994 Nov 4, 2024
0138ac8
Remove extended wp helper
nikolap994 Nov 4, 2024
a2b8396
Fix proper function names
nikolap994 Nov 4, 2024
b931270
Add wp mock function for FacebookPixelTest
nikolap994 Nov 4, 2024
72362af
Remove problematic wp_unsplash from server event factory
nikolap994 Nov 4, 2024
7cdafa9
Add FacebookPixelTest mock events
nikolap994 Nov 4, 2024
84e5f09
Add FacebookServerSideEventTest mock events
nikolap994 Nov 4, 2024
b70608b
Add FacebookWordPressOpenBridgeTest mock events
nikolap994 Nov 4, 2024
7f35713
Add FacebookWordpressSettingsRecorderTest mock events
nikolap994 Nov 4, 2024
fd1e663
Add PixelRendererTest mock events
nikolap994 Nov 4, 2024
0bfb6ce
Add ServerEventFactoryTest mock events
nikolap994 Nov 4, 2024
f687510
Add FacebookWordpressCalderaFormTest mock events
nikolap994 Nov 4, 2024
08c1876
Add FacebookWordpressContactForm7Test mock events
nikolap994 Nov 4, 2024
617fe50
Add FacebookWordpressEasyDigitalDownloadsTest mock events and remove …
nikolap994 Nov 4, 2024
8112d75
Add FacebookWordpressFormidableFormTest mock tests
nikolap994 Nov 4, 2024
ec651c6
Add FacebookWordpressMailchimpForWpTest mock events
nikolap994 Nov 4, 2024
2dddeee
Add FacebookWordpressNinjaFormsTest mock events
nikolap994 Nov 4, 2024
ba3b3aa
Add FacebookWordpressWooCommerceTest mock events
nikolap994 Nov 4, 2024
0cbec19
Add FacebookWordpressWPECommerceTest mock events
nikolap994 Nov 4, 2024
cfbcc3a
Add FacebookWordpressWPFormsTest mock events
nikolap994 Nov 4, 2024
5aaa3d3
Remove redundant escapes
nikolap994 Nov 7, 2024
1d6cb69
Update phpcs with new code style rules
nikolap994 Dec 5, 2024
4b91d09
Update codestyle for core files
nikolap994 Dec 5, 2024
0824b5f
Update code style for integration files
nikolap994 Dec 5, 2024
89b89fc
Update code style for tasks
nikolap994 Dec 5, 2024
e82912a
Update code style for __tests__
nikolap994 Dec 5, 2024
a4db1cb
Run GH actions on all branches
iodic Dec 9, 2024
707e001
Rename GH action
iodic Dec 9, 2024
5f4cd52
Fix updated formidable tests
nikolap994 Dec 9, 2024
f7794e5
Run PHPCS with custom rules in GH actions
iodic Dec 9, 2024
278974e
Remove unused PHPCS config file
iodic Dec 9, 2024
a330fd7
Change pre-commit hook PHPCS ruleset file
iodic Dec 10, 2024
0622d3d
Change indentation in Editorconfig to 2 spaces
iodic Dec 10, 2024
e6ef4d8
Update line length rule to be a warning
iodic Dec 10, 2024
c6ce939
Update indentation rules
iodic Dec 10, 2024
a15cc06
Do not track MacOS system files
iodic Dec 10, 2024
3b6aee2
Update tests code style
iodic Dec 11, 2024
0e120a7
Update integrations code style
iodic Dec 11, 2024
ad3ff8a
Update class code style
iodic Dec 11, 2024
4437be0
Tweak PHPCS rules
iodic Dec 11, 2024
d19c4c4
Test new GH actions VM OS
iodic Dec 11, 2024
05e7557
Set GH Action VM to Ubuntu v22.04
iodic Dec 11, 2024
ac297a9
Do not track editor settings
iodic Dec 11, 2024
1209fd3
Remove Composer executable file
iodic Dec 11, 2024
037c13d
Stop tracking Composer executable file
iodic Dec 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true
2 changes: 1 addition & 1 deletion .githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if [ -n "$php_files" ]; then
echo "Running PHP CodeSniffer on the following files:"
echo "$php_files"

echo "$php_files" | xargs vendor/bin/phpcs -d memory_limit=512M --standard=phpcs.xml.dist
echo "$php_files" | xargs vendor/bin/phpcs -d memory_limit=512M --standard=phpcs.xml
if [ $? -ne 0 ]; then
echo "PHP CodeSniffer failed. Please fix the errors."
exit 1
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
name: Test
name: Unit tests & PHPCS

on:
push:
branches:
- main

jobs:
test-and-code-style:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
strategy:
matrix:
php: [8.1]
Expand All @@ -22,4 +20,4 @@ jobs:
run: vendor/bin/phpunit --bootstrap __tests__/bootstrap.php __tests__

- name: Run PHPCS
run: vendor/bin/phpcs --standard=WordPress --extensions=php --ignore=vendor/ .
run: vendor/bin/phpcs --standard=phpcs.xml --extensions=php --ignore=vendor/ .
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
/build
/js/lib/node_modules
/node_modules
.DS_Store
.vscode
composer.phar
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Run the command to run tests and create the zip under build directory.
2. Extend the class from `FacebookWordpressIntegrationBase`
3. Define class variable `PLUGIN_FILE` to be your plugin PHP file
4. Define class variable `TRACKING_NAME` for tracking purpose, put this value under 'fb_wp_tracking' as a parameter in the pixel event
5. Define a public static function `injectPixelCode()` to inject pixel at your page
5. Define a public static function `inject_pixel_code()` to inject pixel at your page
6. Add your unit test class under `tests/` folder
7. Extend the test class from `FacebookWordpressTestBase`
8. After the classes development, run tests by `$ vendor/bin/phing`
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ https://www.facebook.com/business/help/881403525362441
2. Extend the class from `FacebookWordpressIntegrationBase`
3. Define class variable `PLUGIN_FILE` to be your plugin PHP file
4. Define class variable `TRACKING_NAME` for tracking purpose, put this value under 'fb_wp_tracking' as a parameter in the pixel event
5. Define a public static function `injectPixelCode()` to inject pixel at your page
5. Define a public static function `inject_pixel_code()` to inject pixel at your page
6. Add your unit test class under `tests/` folder
7. Extend the test class from `FacebookWordpressTestBase`
8. After the classes development, run tests by `$ vendor/bin/phing`
Expand Down
220 changes: 149 additions & 71 deletions __tests__/FacebookWordpressTestBase.php
Original file line number Diff line number Diff line change
@@ -1,96 +1,174 @@
<?php
/*
* Copyright (C) 2017-present, Meta, Inc.
/**
* Facebook Pixel Plugin FacebookWordpressTestBase class.
*
* This file contains the main logic for FacebookWordpressTestBase.
*
* @package FacebookPixelPlugin
*/

/**
* Define FacebookWordpressTestBase class.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* @return void
*/

/*
* Copyright (C) 2017-present, Meta, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/

namespace FacebookPixelPlugin\Tests;

use \WP_Mock\Tools\TestCase;
use WP_Mock\Tools\TestCase;
use FacebookPixelPlugin\Core\AAMSettingsFields;
use FacebookAds\Object\ServerSide\AdsPixelSettings;

/**
* FacebookWordpressTestBase class.
*/
abstract class FacebookWordpressTestBase extends TestCase {

public function setUp(): void {
\WP_Mock::setUp();
$GLOBALS['wp_version'] = '1.0';
\Mockery::getConfiguration()->setConstantsMap([
'FacebookPixelPlugin\Core\FacebookPixel' => [
'FB_INTEGRATION_TRACKING_KEY' => 'fb_integration_tracking',
],
]);
/**
* Sets up the environment for each test.
*
* Initializes WP_Mock, sets the global WordPress version,
* configures Mockery constants, and sets server variables
* to simulate an HTTPS request to 'www.pikachu.com'.
*
* @return void
*/
public function setUp(): void {
\WP_Mock::setUp();
$GLOBALS['wp_version'] = '1.0';
\Mockery::getConfiguration()->setConstantsMap(
array(
'FacebookPixelPlugin\Core\FacebookPixel' => array(
'FB_INTEGRATION_TRACKING_KEY' => 'fb_integration_tracking',
),
)
);

$_SERVER['HTTPS'] = 'on';
$_SERVER['HTTP_HOST'] = 'www.pikachu.com';
$_SERVER['REQUEST_URI'] = '/index.php';
}
$_SERVER['HTTPS'] = 'on';
$_SERVER['HTTP_HOST'] = 'www.pikachu.com';
$_SERVER['REQUEST_URI'] = '/index.php';
}

public function tearDown(): void {
/**
* Cleans up the environment after each test.
*
* Asserts that all Mockery expectations have been met, unsets the global
* WordPress version, and calls `tearDown` on WP_Mock.
*
* @return void
*/
public function tearDown(): void {
$this->addToAssertionCount(
\Mockery::getContainer()->mockery_getExpectationCount());
unset($GLOBALS['wp_version']);
\WP_Mock::tearDown();
}
\Mockery::getContainer()->mockery_getExpectationCount()
);
unset( $GLOBALS['wp_version'] );
\WP_Mock::tearDown();
}

protected function mockIsInternalUser($is_internal_user) {
$this->mocked_fbpixel = \Mockery::mock
('alias:FacebookPixelPlugin\Core\FacebookPluginUtils');
$this->mocked_fbpixel->shouldReceive('isInternalUser')
->andReturn($is_internal_user);
}
/**
* Mocks the return value of FacebookPluginUtils::isInternalUser().
*
* @param bool $is_internal_user Whether the user is an internal user.
*
* @return void
*/
protected function mockIsInternalUser( $is_internal_user ) {
$this->mocked_fbpixel =
\Mockery::mock( 'alias:FacebookPixelPlugin\Core\FacebookPluginUtils' );
$this->mocked_fbpixel->shouldReceive( 'is_internal_user' )
->andReturn( $is_internal_user );
}

protected function mockFacebookWordpressOptions($options = array(),
$aam_settings = null){
/**
* Mocks the return value of FacebookWordpressOptions methods.
*
* This function mocks the return values of the FacebookWordpressOptions
* class methods. The $options parameter is an associative array
* where the keys are method names and the values are the return values
* for those methods. If a key is not provided, the method will return
* a default value.
*
* @param array $options An associative
* array of method names and their
* return values.
* @param AdsPixelSettings $aam_settings The return value for the
* get_aam_settings() method.
*/
protected function mockFacebookWordpressOptions(
$options = array(),
$aam_settings = null
) {
$this->mocked_options = \Mockery::mock(
'alias:FacebookPixelPlugin\Core\FacebookWordpressOptions');
if(array_key_exists('agent_string', $options)){
$this->mocked_options->shouldReceive('getAgentString')->andReturn($options['agent_string']);
}
else{
$this->mocked_options ->shouldReceive('getAgentString')
->andReturn('wordpress');
}
if(array_key_exists('pixel_id', $options)){
$this->mocked_options->shouldReceive('getPixelId')->andReturn($options['pixel_id']);
'alias:FacebookPixelPlugin\Core\FacebookWordpressOptions'
);
if ( array_key_exists( 'agent_string', $options ) ) {
$this->mocked_options->shouldReceive( 'get_agent_string' )
->andReturn( $options['agent_string'] );
} else {
$this->mocked_options->shouldReceive( 'get_agent_string' )
->andReturn( 'WordPress' );
}
else{
$this->mocked_options->shouldReceive('getPixelId')->andReturn('1234');
if ( array_key_exists( 'pixel_id', $options ) ) {
$this->mocked_options->shouldReceive( 'get_pixel_id' )
->andReturn( $options['pixel_id'] );
} else {
$this->mocked_options->shouldReceive( 'get_pixel_id' )
->andReturn( '1234' );
}
if(array_key_exists('access_token', $options)){
$this->mocked_options->shouldReceive('getAccessToken')->andReturn($options['access_token']);
if ( array_key_exists( 'access_token', $options ) ) {
$this->mocked_options->shouldReceive( 'get_access_token' )
->andReturn( $options['access_token'] );
} else {
$this->mocked_options->shouldReceive( 'get_access_token' )
->andReturn( 'abcd' );
}
else{
$this->mocked_options->shouldReceive('getAccessToken')->andReturn('abcd');
if ( array_key_exists( 'is_fbe_installed', $options ) ) {
$this->mocked_options->shouldReceive( 'get_is_fbe_installed' )
->andReturn( $options['is_fbe_installed'] );
} else {
$this->mocked_options->shouldReceive( 'get_is_fbe_installed' )
->andReturn( '0' );
}
if(array_key_exists('is_fbe_installed', $options)){
$this->mocked_options->shouldReceive('getIsFbeInstalled')->andReturn($options['is_fbe_installed']);
if ( is_null( $aam_settings ) ) {
$this->mocked_options->shouldReceive( 'get_aam_settings' )
->andReturn( $this->getDefaultAAMSettings() );
} else {
$this->mocked_options->shouldReceive( 'get_aam_settings' )
->andReturn( $aam_settings );
}
else{
$this->mocked_options->shouldReceive('getIsFbeInstalled')->andReturn('0');
$this->mocked_options->shouldReceive( 'get_capi_pii_caching_status' )
->andReturn( 0 );
}
if($aam_settings == null){
$this->mocked_options->shouldReceive('getAAMSettings')->andReturn($this->getDefaultAAMSettings());
}
else{
$this->mocked_options->shouldReceive('getAAMSettings')->andReturn($aam_settings);
}
$this->mocked_options ->shouldReceive('getCapiPiiCachingStatus')
->andReturn(0);
}

protected function getDefaultAAMSettings(){
$aam_settings = new AdsPixelSettings();
$aam_settings->setPixelId('123');
$aam_settings->setEnableAutomaticMatching(true);
$aam_settings->setEnabledAutomaticMatchingFields(AAMSettingsFields::getAllFields());
return $aam_settings;
}

/**
* Returns the default AdsPixelSettings object.
*
* The default AdsPixelSettings object returned by
* this method has the pixel ID
* set to '123', automatic matching enabled, and all
* automatic matching fields
* enabled.
*
* @return AdsPixelSettings The default AdsPixelSettings object.
*/
protected function getDefaultAAMSettings() {
$aam_settings = new AdsPixelSettings();
$aam_settings->setPixelId( '123' );
$aam_settings->setEnableAutomaticMatching( true );
$aam_settings->setEnabledAutomaticMatchingFields( AAMSettingsFields::get_all_fields() );
return $aam_settings;
}
}
32 changes: 28 additions & 4 deletions __tests__/FileNameTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
<?php
/**
* Facebook Pixel Plugin FileNameTest class.
*
* This file contains the main logic for FileNameTest.
*
* @package FacebookPixelPlugin
*/

/**
* Define FileNameTest class.
*
* @return void
*/

/*
* Copyright (C) 2017-present, Meta, Inc.
*
Expand All @@ -11,6 +25,7 @@
* GNU General Public License for more details.
*/


namespace FacebookPixelPlugin\Tests;

use FacebookPixelPlugin\Core\FacebookPixel;
Expand All @@ -22,8 +37,17 @@
* up deactivate the plugin.
**/
final class FileNameTest extends FacebookWordpressTestBase {
public function testEntryPointFileNamePersists() {
$exist = \file_exists(dirname(__FILE__).'/../facebook-for-wordpress.php');
$this->assertTrue($exist);
}
/**
* Check that the name of entry point file
* 'facebook-for-wordpress.php' still
* exist. This is to make sure that the name of
* entry point file is not changed,
* since changing the file name will break how
* WordPress find the plugin file
* and will end up deactivate the plugin.
*/
public function testEntryPointFileNamePersists() {
$exist = \file_exists( __DIR__ . '/../class-facebookforwordpress.php' );
$this->assertTrue( $exist );
}
}
29 changes: 18 additions & 11 deletions __tests__/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
<?php
/*
* Copyright (C) 2017-present, Meta, Inc.
/**
* Define bootstrap.
*
* @package FacebookPixelPlugin
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* @return void
*/

require_once dirname(__FILE__) . '/../vendor/autoload.php';
/*
* Copyright (C) 2017-present, Meta, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/

require_once __DIR__ . '/../vendor/autoload.php';

// Now call the bootstrap method of WP Mock
WP_Mock::bootstrap();
Loading