コード例 #1
0
 public function testSetContentToValidate()
 {
     $content = 'foo';
     $wrapper = new Wrapper();
     $wrapper->createConfiguration(array('url-to-validate' => 'http://example.com/', 'content-to-validate' => $content));
     $this->assertEquals($content, $wrapper->getConfiguration()->getContentToValidate());
 }
 public function testWarningWithVendorSpecificAtRuleErrorsThatShouldBeWarnings()
 {
     $this->wrapper->setCssValidatorRawOutput($this->getFixture('vendor-specific-at-rules.txt'));
     $output = $this->wrapper->validate();
     $this->wrapper->getConfiguration()->setVendorExtensionSeverityLevel(VendorExtensionSeverityLevel::LEVEL_WARN);
     $this->assertEquals(12, $output->getWarningCount());
     $this->assertEquals(1, $output->getErrorCount());
 }
コード例 #3
0
 public function testCurlTimeoutWhenRetrievingCssResourceTwoOfTwo()
 {
     $this->wrapper->setCssValidatorRawOutput($this->getFixture('CssValidatorResponse/1'));
     $output = $this->wrapper->validate();
     $errorsForExceptionedUrl = $output->getErrorsByUrl('http://example.com/assets/css/style2.css');
     $this->assertFalse($output->hasException());
     $this->assertEquals(1, count($errorsForExceptionedUrl));
     $this->assertEquals('curl-error:28', $errorsForExceptionedUrl[0]->getMessage());
 }
コード例 #4
0
 public function testEnabledWithVendorExtensionAtRuleErrorsAndVendorExtensionIssuesAsWarnings()
 {
     $this->wrapper->setCssValidatorRawOutput($this->getFixture('vendor-specific-at-rules.txt'));
     $this->wrapper->getConfiguration()->setFlag(Flags::FLAG_IGNORE_WARNINGS);
     $output = $this->wrapper->validate();
     $this->wrapper->getConfiguration()->setVendorExtensionSeverityLevel(VendorExtensionSeverityLevel::LEVEL_WARN);
     $this->assertEquals(0, $output->getWarningCount());
     $this->assertEquals(1, $output->getErrorCount());
 }
コード例 #5
0
 public function testHttp404WhenRetrievingCssResourcesOneAndTwo()
 {
     $this->wrapper->setCssValidatorRawOutput($this->getFixture('CssValidatorResponse/1'));
     $output = $this->wrapper->validate();
     $errorsForStylesheet1 = $output->getErrorsByUrl('http://example.com/assets/css/style1.css');
     $this->assertFalse($output->hasException());
     $this->assertEquals(1, count($errorsForStylesheet1));
     $this->assertEquals('http-error:404', $errorsForStylesheet1[0]->getMessage());
     $errorsForStylesheet2 = $output->getErrorsByUrl('http://example.com/assets/css/style2.css');
     $this->assertFalse($output->hasException());
     $this->assertEquals(1, count($errorsForStylesheet2));
     $this->assertEquals('http-error:404', $errorsForStylesheet2[0]->getMessage());
 }
コード例 #6
0
 public function testSet()
 {
     $this->getHttpClient()->setDefaultOption('auth', ['example_user', 'example_password']);
     $this->wrapper->getConfiguration()->setHttpClient($this->getHttpClient());
     $this->wrapper->setCssValidatorRawOutput($this->getFixture('CssValidatorResponse/1'));
     #
     $output = $this->wrapper->validate();
     $this->assertFalse($output->hasException());
     $this->assertEquals(3, $output->getErrorCount());
     foreach ($output->getMessages() as $message) {
         $this->assertTrue(substr_count($message->getRef(), 'file:/') === 0);
     }
 }
コード例 #7
0
 /**
  * 
  * @return array
  */
 protected function getRawValidatorOutputLines()
 {
     if (is_null($this->cssValidatorRawOutput)) {
         if ($this->deferToParentIfNoRawOutput) {
             return parent::getRawValidatorOutputLines();
         }
         return null;
     }
     return explode("\n", $this->cssValidatorRawOutput);
 }
コード例 #8
0
 public function testThreeDomainsOfThreeIgnored()
 {
     $this->wrapper->getConfiguration()->setDomainsToIgnore(array('one.cdn.example.com', 'two.cdn.example.com', 'example.com'));
     $this->assertEquals(0, $this->wrapper->validate()->getErrorCount());
 }
コード例 #9
0
 public function testMangledMarkupWithValidContentTypeDoesNotGenerateInvalidContentTypeError()
 {
     $output = $this->wrapper->validate();
     $this->assertFalse($output->hasException());
 }
 public function testWithCssContent()
 {
     $this->wrapper->getConfiguration()->setContentToValidate(file_get_contents($this->getFixturesDataPath() . '/WebResourceContent/content.css'));
     $this->assertEquals(0, $this->wrapper->validate()->getErrorCount());
 }
コード例 #11
0
 public function testHasConfigurationWhenConfigurationIsSet()
 {
     $wrapper = new CssValidatorWrapper();
     $this->assertTrue($wrapper->setConfiguration(new Configuration())->hasConfiguration());
 }
コード例 #12
0
 public function testMissingClosingAngleBracketOnStylesheetLink()
 {
     $output = $this->wrapper->validate();
     $this->assertFalse($output->hasException());
 }
 public function testDisableRetryWithUrlEncodingDisabledHasErrorForS1Url()
 {
     $this->wrapper->getConfiguration()->getWebResourceService()->getConfiguration()->disableRetryWithUrlEncodingDisabled();
     $output = $this->wrapper->validate();
     $this->assertEquals(1, count($output->getErrorsByUrl('http://s1.example.com/?%3Fstyle.css')));
 }
 public function testDoubleQuotesAreEscaped()
 {
     $this->wrapper->setCssValidatorRawOutput($this->getFixture('double-quote-in-ref-url.txt'));
     $output = $this->wrapper->validate();
     $this->assertEquals(1, $output->getErrorCount());
 }
 public function testTest()
 {
     $this->wrapper->getConfiguration()->getWebResourceService()->getConfiguration()->enableRetryWithUrlEncodingDisabled();
     $output = $this->wrapper->validate();
     $this->assertEquals(0, $output->getErrorCount());
 }
 public function testTest()
 {
     $output = $this->wrapper->validate();
     $this->assertFalse($output->hasException());
 }