Skip to content

Commit

Permalink
Merge adbf2ea into 0ddf921
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonbahl committed Nov 16, 2017
2 parents 0ddf921 + adbf2ea commit 769271c
Show file tree
Hide file tree
Showing 35 changed files with 755 additions and 3,932 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ vendor/ivome/graphql-relay-php/*
!vendor/autoload.php
!vendor/composer
vendor/composer/installed.json
vendor/composer/*/
!/tests
build/
coverage/*
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,18 @@ matrix:

install:
- cd $TRAVIS_BUILD_DIR
# Install composer packages, will also trigger dump-autoload
- composer install
# Install WP CLI
- curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
- chmod +x wp-cli.phar
- sudo mv wp-cli.phar /usr/local/bin/wp

before_script:
# Install WordPress and the Test Suite
- bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION
- bash bin/install-wp-tests.sh wpgraphql_test root '' 127.0.0.1 $WP_VERSION
# Update composer
- composer self-update
# Install APIGen and PHPUnit, using the specified version for the PHP version we're running
- composer require apigen/apigen:^4.1 phpunit/phpunit:$PHP_UNIT_VERSION
- composer require apigen/apigen:^4.1 lucatume/wp-browser:~1.21.20
- composer install --no-interaction
# Make a directory for storing logs
- mkdir -p build/logs
Expand All @@ -72,9 +70,11 @@ script:
- |
if [ $COVERAGE == true ]; then
vendor/bin/phpunit --group ajax
vendor/bin/codecept run wpunit
vendor/bin/phpunit --coverage-clover build/logs/clover.xml
else
vendor/bin/phpunit --group ajax --no-coverage
vendor/bin/codecept run wpunit
vendor/bin/phpunit --no-coverage
fi
Expand Down
9 changes: 4 additions & 5 deletions bin/install-wp-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ install_db() {
mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA
fi

RESULT_2=`mysql -u $DB_USER --password="$DB_PASS" --skip-column-names -e "SHOW DATABASES LIKE '$DB_SERVE_NAME'"`
RESULT_2=`mysql -u $DB_USER --password="$DB_PASS" --skip-column-names -e "SHOW DATABASES LIKE '$DB_SERVE_NAME'"`
if [ "$RESULT_2" != $DB_SERVE_NAME ]; then
mysqladmin create $DB_SERVE_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA
fi
Expand All @@ -139,7 +139,6 @@ configure_wordpress() {
wp config create --dbname="$DB_SERVE_NAME" --dbuser=root --dbpass="$DB_PASS" --dbhost="$DB_HOST" --skip-check --force=true
wp core install --url=wpgraphql.test --title="WPGraphQL Tests" --admin_user=admin --admin_password=password --admin_email=admin@wpgraphql.test
wp rewrite structure '/%year%/%monthnum%/%postname%/'

}

activate_plugin() {
Expand All @@ -152,11 +151,11 @@ activate_plugin() {
# activate the plugin
wp plugin activate wp-graphql

# List active plugins
wp plugin list

# Flush the permalinks
wp rewrite flush

# Export the db for codeception to use
wp db export $PLUGIN_DIR/tests/_data/dump.sql
}

install_wp
Expand Down
20 changes: 20 additions & 0 deletions codeception.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
paths:
tests: tests
output: tests/_output
data: tests/_data
support: tests/_support
envs: tests/_envs
actor_suffix: Tester
extensions:
enabled:
- Codeception\Extension\RunFailed
commands:
- Codeception\Command\GenerateWPUnit
- Codeception\Command\GenerateWPRestApi
- Codeception\Command\GenerateWPRestController
- Codeception\Command\GenerateWPRestPostTypeController
- Codeception\Command\GenerateWPAjax
- Codeception\Command\GenerateWPCanonical
- Codeception\Command\GenerateWPXMLRPC
- Codeception\Command\DbSnapshot
- tad\Codeception\Command\SearchReplace
4 changes: 0 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@
"webonyx/graphql-php": "^0.11.2",
"ivome/graphql-relay-php": "^0.3.1"
},
"require-dev": {
"phpunit/phpunit": "5.6",
"satooshi/php-coveralls": "~1.0"
},
"config": {
"optimize-autoloader": true
},
Expand Down
4 changes: 2 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 0 additions & 33 deletions src/Type/CommentAuthor/CommentAuthorQuery.php

This file was deleted.

Empty file added tests/_data/.gitkeep
Empty file.
7 changes: 7 additions & 0 deletions tests/_data/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
/**
* Disable autoloading while running tests, as the test
* suite already bootstraps the autoloader and creates
* fatal errors when the autoloader is loaded twice
*/
define( 'WPGRAPHQL_AUTOLOAD', false );
409 changes: 409 additions & 0 deletions tests/_data/dump.sql

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions tests/_output/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
26 changes: 26 additions & 0 deletions tests/_support/AcceptanceTester.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php


/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
*
* @SuppressWarnings(PHPMD)
*/
class AcceptanceTester extends \Codeception\Actor
{
use _generated\AcceptanceTesterActions;

/**
* Define custom actions here
*/
}
26 changes: 26 additions & 0 deletions tests/_support/FunctionalTester.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php


/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
*
* @SuppressWarnings(PHPMD)
*/
class FunctionalTester extends \Codeception\Actor
{
use _generated\FunctionalTesterActions;

/**
* Define custom actions here
*/
}
10 changes: 10 additions & 0 deletions tests/_support/Helper/Acceptance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
namespace Helper;

// here you can define custom actions
// all public methods declared in helper class will be available in $I

class Acceptance extends \Codeception\Module
{

}
10 changes: 10 additions & 0 deletions tests/_support/Helper/Functional.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
namespace Helper;

// here you can define custom actions
// all public methods declared in helper class will be available in $I

class Functional extends \Codeception\Module
{

}
10 changes: 10 additions & 0 deletions tests/_support/Helper/Unit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
namespace Helper;

// here you can define custom actions
// all public methods declared in helper class will be available in $I

class Unit extends \Codeception\Module
{

}
10 changes: 10 additions & 0 deletions tests/_support/Helper/Wpunit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
namespace Helper;

// here you can define custom actions
// all public methods declared in helper class will be available in $I

class Wpunit extends \Codeception\Module
{

}
26 changes: 26 additions & 0 deletions tests/_support/UnitTester.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php


/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
*
* @SuppressWarnings(PHPMD)
*/
class UnitTester extends \Codeception\Actor
{
use _generated\UnitTesterActions;

/**
* Define custom actions here
*/
}
26 changes: 26 additions & 0 deletions tests/_support/WpunitTester.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php


/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
*
* @SuppressWarnings(PHPMD)
*/
class WpunitTester extends \Codeception\Actor
{
use _generated\WpunitTesterActions;

/**
* Define custom actions here
*/
}
2 changes: 2 additions & 0 deletions tests/_support/_generated/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
29 changes: 29 additions & 0 deletions tests/acceptance.suite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Codeception Test Suite Configuration
#
# Suite for acceptance tests.
# Perform tests in browser using the WPWebDriver or WPBrowser.
# Use WPDb to set up your initial database fixture.
# If you need both WPWebDriver and WPBrowser tests - create a separate suite.

actor: AcceptanceTester
modules:
enabled:
- WPDb
- WPBrowser
- \Helper\Acceptance
config:
WPDb:
dsn: 'mysql:host=127.0.0.1;dbname=wpgraphql_serve'
user: 'root'
password: 'jbutt#123'
dump: 'tests/_data/dump.sql'
populate: true #import the dump before the tests
cleanup: true #import the dump between tests
url: 'http://wp.localhost'
urlReplacement: true #replace the hardcoded dump URL with the one above
tablePrefix: 'wp_'
WPBrowser:
url: 'http://wp.localhost'
adminUsername: 'admin'
adminPassword: 'password'
adminPath: '/wp-admin'
29 changes: 29 additions & 0 deletions tests/functional.suite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Codeception Test Suite Configuration
#
# Suite for functional tests
# Emulate web requests and make WordPress process them

actor: FunctionalTester
modules:
enabled:
- WPDb
- WordPress
- Asserts
- \Helper\Functional
config:
WPDb:
dsn: 'mysql:host=127.0.0.1;dbname=wpgraphql_serve'
user: 'root'
password: 'jbutt#123'
dump: 'tests/_data/dump.sql'
populate: true
cleanup: true
url: 'http://wp.localhost'
urlReplacement: true
tablePrefix: 'wp_'
WordPress:
depends: WPDb
wpRootFolder: '/tmp/wordpress'
adminUsername: 'admin'
adminPassword: 'password'
adminPath: '/wp-admin'
Loading

0 comments on commit 769271c

Please sign in to comment.