File: PHPCodeSniffer.pm

package info (click to toggle)
libcode-tidyall-perl 0.83~ds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,036 kB
  • sloc: perl: 5,240; lisp: 47; makefile: 2; sh: 1
file content (43 lines) | stat: -rw-r--r-- 1,144 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package TestFor::Code::TidyAll::Plugin::PHPCodeSniffer;

use Path::Tiny qw( cwd );
use Test::Class::Most parent => 'TestFor::Code::TidyAll::Plugin';

sub test_filename {'foo.php'}

sub _extra_path {
    cwd()->child(qw( php PHP_CodeSniffer bin ));
}

sub test_main : Tests {
    my $self = shift;

    # This fails in Azure Pipelines under Windows for some reason that I
    # cannot figure out.
    if ( $^O eq 'MSWin32' && $ENV{BUILD_BUILDID} ) {
        $self->builder->skip('These tests fail on Windows in CI');
        return;
    }
    return unless $self->require_executable('php');
    return unless $self->require_executable('phpcs');

    my $source = '<?php function foo() { $bar = 5 } ?>';

    $self->tidyall(
        source    => $source,
        conf      => { argv => '--severity=6' },
        expect_ok => 1,
    );
    $self->tidyall(
        source       => $source,
        conf         => { argv => '--severity=3' },
        expect_error => qr/Missing .* doc/,
    );
    $self->tidyall(
        source       => $source,
        conf         => { argv => '--blahblah' },
        expect_error => qr/not known/,
    );
}

1;