<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="PHP_CodeSniffer" xsi:noNamespaceSchemaLocation="phpcs.xsd">
    <description>Coding Standards for Tests</description>

    <!-- Inspect files in the /tests folder -->
    <file>tests</file>

    <!-- Run in verbose mode and specify the precise rule that failed in output -->
    <arg value="sv"/>
    <arg name="colors"/>

    <!-- Check that code meets WordPress-Extra standards. -->
    <rule ref="WordPress-Extra">
        <!-- Don't use yoda conditions -->
        <exclude name="WordPress.PHP.YodaConditions" />

        <!-- File and variable naming conventions in Codeception differ from WordPress -->
        <exclude name="WordPress.NamingConventions" />
        <exclude name="WordPress.Files.FileName" />

        <!-- Class and function braces and spacing in Codeceptoin differs from WordPress -->
        <exclude name="WordPress.WhiteSpace.ControlStructureSpacing.NoSpaceAfterOpenParenthesis" />
        <exclude name="WordPress.WhiteSpace.ControlStructureSpacing.ExtraSpaceAfterCloseParenthesis" />
        <exclude name="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingAfterOpen" />
        <exclude name="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingBeforeClose" />
        <exclude name="WordPress.WhiteSpace.ControlStructureSpacing.NoSpaceBeforeCloseParenthesis" />
        <exclude name="Generic.Classes.OpeningBraceSameLine.BraceOnNewLine" />
        <exclude name="Generic.Functions.OpeningFunctionBraceKernighanRitchie.BraceOnNewLine" />
        <exclude name="PEAR.Functions.FunctionCallSignature.SpaceBeforeOpenBracket" />
        <exclude name="PEAR.Functions.FunctionCallSignature.SpaceAfterOpenBracket" />
        <exclude name="PEAR.Functions.FunctionCallSignature.SpaceBeforeCloseBracket" />
        <exclude name="Squiz.Functions.MultiLineFunctionDeclaration.SpaceAfterFunction" />

        <!-- _before() and _passed() must use underscores in Codeception -->
        <exclude name="PSR2.Methods.MethodDeclaration.Underscore" />

        <!-- Permit [] instead of array() -->
        <exclude name="Universal.Arrays.DisallowShortArraySyntax.Found" />

        <!-- We might use some datetime functions for tests -->
        <exclude name="WordPress.DateTime.RestrictedFunctions" />

        <!-- Handles false positives where Coding Standards thinks we did something wrong when we're just checking for e.g. a stylesheet -->
        <exclude name="WordPress.WP.EnqueuedResources" />
        <exclude name="WordPress.PHP.DiscouragedPHPFunctions" />
        <exclude name="WordPress.WP.CapitalPDangit.MisspelledInText" />
    </rule>

    <!-- Check that code is documented to WordPress Standards. -->
    <rule ref="WordPress-Docs">
        <!-- File document level comments are useless for tests; we know what a test suite does -->
        <exclude name="Squiz.Commenting.FileComment.Missing" />
    </rule>

    <!-- Add in some extra rules from other standards. -->
    <rule ref="Generic.CodeAnalysis.UnusedFunctionParameter"/>
    <rule ref="Generic.Commenting.Todo"/>
</ruleset>