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

Adds Hermes #8

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
a47de24
Finish up relationships
speerface Dec 26, 2024
e9d4b2d
Add test for arguments token
speerface Dec 27, 2024
94e0379
Add in field token tests
speerface Dec 27, 2024
a82dec5
Get nested queries working
speerface Dec 31, 2024
4a6f219
Add full handling
speerface Dec 31, 2024
4da35cf
Finish up initial query work
speerface Jan 4, 2025
d8e17b9
Add in insertion mutation
speerface Jan 6, 2025
ff36d54
Remove var dump
speerface Jan 6, 2025
8447c82
Add in support for field type validation for mutations
speerface Jan 20, 2025
b1b0583
Add in test coverage for field type validation
speerface Jan 20, 2025
902e9c2
Add in tests for custom callbacks
speerface Jan 20, 2025
c5f77c3
Add in support for update mutations
speerface Jan 21, 2025
c59bac4
Add in delete handling
speerface Jan 22, 2025
eb764d6
Add in connect mutation type
speerface Jan 22, 2025
2cffcfa
Add in wp-unit tests to avoid mocking functions
speerface Jan 23, 2025
00e132c
Merge branch 'master' into feature-hermes
speerface Jan 23, 2025
3976775
Add in DB tests for all the mutation types
speerface Jan 23, 2025
efb89b0
Move mutation token types to their own directories
speerface Jan 23, 2025
5a5e9e4
Move mutation logic to individual runners
speerface Jan 23, 2025
cef7ca9
Make sure all tests run and pass
speerface Jan 23, 2025
248dc69
Docblock enumbs
speerface Jan 24, 2025
1c2d12e
Docblock base model
speerface Jan 24, 2025
1b87f40
Docblock runner
speerface Jan 24, 2025
5608467
Docblock individual runners
speerface Jan 24, 2025
7fc98cf
Docblock utils
speerface Jan 26, 2025
d0da737
Docblock query handler
speerface Jan 26, 2025
e6967c7
Docblock Mutation handler
speerface Jan 26, 2025
9c6494f
Docblock tokens
speerface Jan 26, 2025
974b3b7
Begin readme
speerface Jan 26, 2025
ee9a066
Finish up readme first pass
speerface Jan 26, 2025
203000d
Fix namespace for generic mutation
speerface Jan 28, 2025
ffc83f6
Add specific error codes
speerface Jan 28, 2025
eac9f8c
Make query handler echo
speerface Jan 28, 2025
9f2acea
Add instructions for actually using Hermes to the README
speerface Jan 31, 2025
24fba1b
Add boolean to enum
speerface Feb 3, 2025
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea
vendor
.phpunit.result.cache
.phpunit.result.cache
/wp-tests-config.php
108 changes: 108 additions & 0 deletions bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<?php

use Gravity_Forms\Gravity_Tools\Hermes\Enum\Field_Type_Validation_Enum;
use tad\FunctionMocker\FunctionMocker;

require_once dirname( __FILE__ ) . '/vendor/autoload.php';

FunctionMocker::init();

/**
* Bootstrap for WP Unit Tests
*/
require __DIR__ . '/wp-loader.php';
$core_loader = new WpLoader();
$core_loader->init();

class FakeContactModel extends \Gravity_Forms\Gravity_Tools\Hermes\Models\Model {

protected $type = 'contact';

protected $access_cap = 'manage_options';

public function fields() {
return array(
'id' => Field_Type_Validation_Enum::INT,
'first_name' => Field_Type_Validation_Enum::STRING,
'last_name' => Field_Type_Validation_Enum::STRING,
'email' => Field_Type_Validation_Enum::EMAIL,
'phone' => Field_Type_Validation_Enum::STRING,
'foobar' => function ( $value ) {
if ( $value === 'foo' ) {
return 'foo';
}

return null;
},
);
}

public function meta_fields() {
return array(
'secondary_phone' => Field_Type_Validation_Enum::STRING,
'alternate_website' => Field_Type_Validation_Enum::STRING,
);
}

public function relationships() {
return new \Gravity_Forms\Gravity_Tools\Hermes\Utils\Relationship_Collection();
}

}

class FakeGroupModel extends \Gravity_Forms\Gravity_Tools\Hermes\Models\Model {

protected $type = 'group';

protected $fields = array(
'label',
);

public function fields() {
return array(
'label' => Field_Type_Validation_Enum::STRING,
);
}

protected $access_cap = 'manage_options';

public function relationships() {
return new \Gravity_Forms\Gravity_Tools\Hermes\Utils\Relationship_Collection(
array(
new \Gravity_Forms\Gravity_Tools\Hermes\Utils\Relationship( 'group', 'contact', 'manage_options' )
)
);
}

}

function gravitytools_tests_reset_db() {
echo "\r\n";
echo '=========================================' . "\r\n";
echo 'Cleaning up test database for next run...' . "\r\n";
global $wpdb;

$tables = array(
'contact',
'company',
'group',
'deal',
'pipeline',
'company_contact',
'group_contact',
'deal_company',
'deal_contact',
'pipeline_deal',
'meta',
);

foreach( $tables as $table ) {
$table_name = sprintf( '%s%s_%s', $wpdb->prefix, 'gravitycrm', $table );
$sql = sprintf( 'TRUNCATE TABLE %s', $table_name );
$wpdb->query( $sql );
}

echo 'Done cleaning test database!' . "\r\n";
echo '=========================================' . "\r\n";
echo "\r\n";
}
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
],
"minimum-stability": "stable",
"require-dev": {
"phpunit/phpunit": ">4.0 <7"
"phpunit/phpunit": "7.5.9",
"yoast/phpunit-polyfills": "3.1.1"
},
"require": {
"lucatume/function-mocker": "~1.0"
}
}
Loading