Skip to content

Adds Hermes #8

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

Open
wants to merge 86 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 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
c86c547
Add more test coverage
speerface Mar 7, 2025
35f0bb6
Merge branch 'master' into feature-hermes
speerface Mar 11, 2025
7f747bd
Remove function mock for translating
speerface Mar 11, 2025
69198d0
Add in handling for overridden table names
speerface Mar 17, 2025
4adbe27
Merge latest upstream
speerface Mar 17, 2025
47b59de
Merge latest upstream
speerface Mar 18, 2025
3ea6d7f
Fix method call
speerface Mar 18, 2025
7717fbf
Merge branch 'master' into feature-hermes
speerface Mar 18, 2025
f5135eb
Add in transformation support
speerface Mar 21, 2025
3526dd3
Remove some old code
speerface Mar 24, 2025
7570e72
Fix PHP 8 fatal
speerface Mar 24, 2025
6ce74e9
Fix issue with multiple related objects not being recognized
speerface Mar 26, 2025
27b3577
Add agg support to queries
speerface Mar 26, 2025
4a6d103
Make aggregate work properly
speerface Mar 26, 2025
35bf869
Fix issue when no where args are passed
speerface Mar 27, 2025
2cf42fb
Fix issue with empty args
speerface Mar 27, 2025
dad17b2
Ensure date fields are updated and set when inserting/updating records
speerface Mar 27, 2025
9ae6d9e
Add in ordering
speerface Mar 27, 2025
d7703e2
Pass table alias
speerface Mar 27, 2025
e683e5e
Pass table_alias as arg
speerface Mar 27, 2025
c4eade3
Remove order args from field list
speerface Mar 27, 2025
83d7cb0
Change casing of dateUpdated and dateCreated
speerface Mar 31, 2025
df2a891
Add in ability to run multiple connect mutations in a single call
speerface Apr 1, 2025
6b380b8
Begin work on allowing full related objects to be inserted in a singl…
speerface Apr 2, 2025
ad1efc0
Finish up related object insertions
speerface Apr 3, 2025
2c66960
Fix connections for sub-sub-children
speerface Apr 3, 2025
b4da648
Fix related inserts
speerface Apr 7, 2025
eb6b2ac
Add in schema querying
speerface Apr 9, 2025
0cb7c0f
Add in disconnect mutation
speerface Apr 17, 2025
37226bc
Remove vardump
speerface Apr 17, 2025
e4542ff
Add in ability to filter token and mutation types
speerface Apr 17, 2025
cf630d5
Strip quotes from argument values
speerface Apr 22, 2025
a7cbdb6
Update parsing for argument pairs to support special characters
speerface May 1, 2025
065329c
Update delete to allow multiples and/or all
speerface May 12, 2025
15e4e1e
Add in search capabilities
speerface May 13, 2025
3b68010
Add table alias to search fields
speerface May 13, 2025
b446bb4
Make clauses separate
speerface May 13, 2025
6b6d5ec
Fix search
speerface May 13, 2025
5d5d418
Allow booleans in update
speerface May 28, 2025
bb5ed28
Fix booleans
speerface May 28, 2025
d6794c1
Fix values that come at the end of args
speerface May 29, 2025
89cb421
Add in aggregate search
speerface Jun 3, 2025
f6cfce5
Remove debug dump
speerface Jun 3, 2025
1a8ded4
Make is_reverse accessible
speerface Jun 3, 2025
58f9b9c
Fix query format
speerface Jun 3, 2025
eed69a6
Alias to id
speerface Jun 3, 2025
96bd27c
Update connect calls to use an array syntax
speerface Jun 10, 2025
a3dfd80
Do not return early if check finds existing connection
speerface Jun 10, 2025
b0a4381
Update to allow returning instead of echoing
speerface Jun 18, 2025
34a932e
Make query return if passed
speerface Jun 18, 2025
8d912c8
Remove continue to allow multiple levels of nesting
speerface Jun 19, 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
206 changes: 206 additions & 0 deletions bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
<?php

use Gravity_Forms\Gravity_Tools\Hermes\Enum\Field_Type_Validation_Enum;
use Gravity_Forms\Gravity_Tools\Hermes\Utils\Relationship;
use Gravity_Forms\Gravity_Tools\Hermes\Utils\Relationship_Collection;
use tad\FunctionMocker\FunctionMocker;

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

FunctionMocker::init();

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

class FakeWebsiteModel extends \Gravity_Forms\Gravity_Tools\Hermes\Models\Model {
protected $type = 'website';
protected $access_cap = 'manage_options';

public function fields() {
return array(
'id' => Field_Type_Validation_Enum::INT,
'type' => Field_Type_Validation_Enum::STRING,
'url' => Field_Type_Validation_Enum::STRING,
);
}

public function relationships() {
return new Relationship_Collection( array() );
}
}

class FakePhoneModel extends \Gravity_Forms\Gravity_Tools\Hermes\Models\Model {
protected $type = 'phone';
protected $access_cap = 'manage_options';

public function fields() {
return array(
'id' => Field_Type_Validation_Enum::INT,
'type' => Field_Type_Validation_Enum::STRING,
'number' => Field_Type_Validation_Enum::INT,
'countryCode' => Field_Type_Validation_Enum::STRING,
);
}

public function relationships() {
return new Relationship_Collection( array() );
}
}

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

protected $type = 'email';

protected $access_cap = 'manage_options';

public function fields() {
return array(
'id' => Field_Type_Validation_Enum::INT,
'address' => Field_Type_Validation_Enum::STRING,
'type' => Field_Type_Validation_Enum::STRING,
);
}

public function relationships() {
return new Relationship_Collection( array() );
}
}

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,
'firstName' => Field_Type_Validation_Enum::STRING,
'lastName' => Field_Type_Validation_Enum::STRING,
'profile_picture' => Field_Type_Validation_Enum::INT,
'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 transformations() {
return array(
'transformMakeThumb' => function ( $thumb_type, $thumb_id ) {
return sprintf( 'thumbnail_url:%s/%s', $thumb_type, $thumb_id );
},
);
}

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

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

protected $type = 'company';

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

protected $access_cap = 'manage_options';

public function relationships() {
$relationships = array(
new Relationship( 'company', 'contact', 'manage_options' ),
new Relationship( 'company', 'email', 'manage_options' ),
new Relationship( 'company', 'phone', 'manage_options' ),
new Relationship( 'company', 'website', 'manage_options' ),
);

return new Relationship_Collection( $relationships );
}
}

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',
'meta',
'email',
'contact_email',
'phone',
'website',
'company_phone',
'company_website',
'company_email',
);

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