Skip to content

Instantly share code, notes, and snippets.

@Shelob9
Created March 6, 2018 21:19
Show Gist options
  • Save Shelob9/9a34a4e4a805ad0f8c670f8e69ee1ed8 to your computer and use it in GitHub Desktop.
Save Shelob9/9a34a4e4a805ad0f8c670f8e69ee1ed8 to your computer and use it in GitHub Desktop.
{
"name": "caldera-learn/rest-api-search",
"description": "Example code for a plugin that modifies default post routes to improve search",
"type": "wordpress-plugin",
"require-dev": {
"php": "^7.1",
"phpunit/phpunit": "^7.0",
"squizlabs/php_codesniffer": "^3.2",
"jakub-onderka/php-parallel-lint": "^1.0",
"brainmaestro/composer-git-hooks": "^2.4"
},
"license": "GPL-2.0",
"authors": [
{
"name": "Josh Pollock",
"email": "josh@calderawp.com"
}
],
"require": {},
"scripts" : {
"tests" : "composer fixes && composer sniffs && composer test",
"test": "composer unit-tests",
"unit-tests": "phpunit --testsuite=unit",
"phpunit-v": "phpunit --version",
"sniffs" : "phpcs src/ && phpcs tests/",
"fixes" : "phpcbf src/ && phpcbf tests/",
"lints" : "parallel-lint ./src --blame --exclude vendor && parallel-lint ./tests --blame --exclude vendor",
"post-install-cmd": "vendor/bin/cghooks add --ignore-lock",
"post-update-cmd": "vendor/bin/cghooks update"
},
"autoload": {
"psr-4": {
"CalderaLearn\\RestSearch\\": "src"
},
"files": ["src/functions.php"]
},
"autoload-dev": {
"psr-4": {
"CalderaLearn\\RestSearch\\Tests\\": "tests/"
},
"files": ["Tests/Mock/WP_Post.php"]
},
"extra": {
"hooks": {
"pre-commit": "composer fixes && composer sniffs"
}
}
}
<?php
namespace CalderaLearn\RestSearch\Tests\Unit;
/**
* Class ExampleTest
*
* An example unit test
*
* @package CalderaLearn\RestSearch\Tests\Unit
*/
class ExampleTest extends TestCase
{
/**
* Super basic test for educational purposes
*
* @covers TestCase
*/
public function testTheTruth()
{
//What should the value be?
$excepted = true;
//What is the value actually
$actual = false;
//Are they not the same?
$this->assertNotEquals($excepted, $actual);
}
}
<?xml version="1.0"?>
<!--Largely Sourced Form https://gist.github.com/gsherwood/9d22f634c57f990a7c64-->
<ruleset name="CalderaLearn">
<description>PSR2 with tabs instead of spaces.</description>
<arg name="tab-width" value="4"/>
<rule ref="PSR2">
<exclude name="Generic.WhiteSpace.DisallowTabIndent"/>
</rule>
<rule ref="Generic.WhiteSpace.DisallowSpaceIndent"/>
<rule ref="Generic.WhiteSpace.ScopeIndent">
<properties>
<property name="indent" value="4"/>
<property name="tabIndent" value="true"/>
</properties>
</rule>
<!-- The soft limit on line length MUST be 120 characters; automated style checkers MUST warn but MUST NOT error at the soft limit. -->
<rule ref="Generic.Files.LineLength">
<properties>
<property name="lineLimit" value="120"/>
<property name="absoluteLineLimit" value="0"/>
</properties>
</rule>
</rulese
<?php
namespace CalderaLearn\RestSearch\Tests\Unit;
//Import PHP unit test case.
//Must be aliased to avoid having two classes of same name in scope.
use PHPUnit\Framework\TestCase as FrameworkTestCase;
/**
* Class TestCase
*
* Default test case for all unit tests
* @package CalderaLearn\RestSearch\Tests\Unit
*/
abstract class TestCase extends FrameworkTestCase
{
//We'll put shared code for all tests here later
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment