Example #1
0
 public function testResetBoth()
 {
     $rule = new Rule();
     $rule->addWarning(array('message' => 'Warning', 'line' => 0));
     $rule->addViolation(array('message' => 'Violation', 'line' => 0));
     $rule->reset();
     $this->assertIdentical(0, count($rule->warnings()));
     $this->assertIdentical(0, count($rule->violations()));
 }
Example #2
0
    public function testApplyWithViolation()
    {
        $rule = new MockRule();
        $violation = array('message' => 'foobar', 'line' => 0, 'position' => 0);
        $rule->addViolation($violation);
        $testable = new MockTestable(array('wrap' => false, 'source' => <<<EOD
<?php
echo 'foobar';
EOD
));
        $this->subject->add($rule);
        $results = $this->subject->apply($testable);
        $this->assertIdentical(array($violation), $results['violations']);
        $this->assertIdentical(array(), $results['warnings']);
        $this->assertIdentical(false, $results['success']);
    }