public function testSetGetCssValdiatorPath()
 {
     $cssValidatorPath = '/home/user/css-validator.jar';
     $configuration = new Configuration();
     $configuration->setCssValidatorJarPath($cssValidatorPath);
     $this->assertEquals($cssValidatorPath, $configuration->getCssValidatorJarPath());
 }
 public function testSetGetDomainsToIgnore()
 {
     $domainsToIgnore = array('foo', 'bar');
     $configuration = new Configuration();
     $configuration->setDomainsToIgnore($domainsToIgnore);
     $this->assertEquals($domainsToIgnore, $configuration->getDomainsToIgnore());
 }
 public function testSetGetJavaExecutablePath()
 {
     $javaExecutablePath = '/usr/bin/uncommon/java';
     $configuration = new Configuration();
     $configuration->setJavaExecutablePath($javaExecutablePath);
     $this->assertEquals($javaExecutablePath, $configuration->getJavaExecutablePath());
 }
 public function testSetGetUrlToValidate()
 {
     $urlToValidate = 'http://example.com/';
     $configuration = new Configuration();
     $configuration->setUrlToValidate($urlToValidate);
     $this->assertEquals($urlToValidate, $configuration->getUrlToValidate());
 }
 public function testSetAllClearAllHasNone()
 {
     $configuration = new Configuration();
     foreach (Flags::getValidValues() as $flag) {
         $configuration->setFlag($flag);
         $configuration->clearFlag($flag);
         $this->assertFalse($configuration->hasFlag($flag));
     }
 }
 public function setUp()
 {
     $this->setTestFixturePath(__CLASS__, $this->getName());
     $this->setHttpFixtures($this->getHttpFixtures($this->getFixturesDataPath() . '/HttpResponses'));
     $configuration = new Configuration();
     $configuration->setUrlToValidate('http://en.wikipedia.org/');
     $configuration->setHttpClient($this->getHttpClient());
     $this->wrapper = $this->getNewCssValidatorWrapper();
     $this->wrapper->setConfiguration($configuration);
     $this->wrapper->setCssValidatorRawOutput($this->getFixture('/CssValidatorOutput/1'));
 }
 public function setUp()
 {
     $this->setTestFixturePath(__CLASS__, $this->getName());
     $this->setHttpFixtures($this->getHttpFixtures($this->getFixturesDataPath() . '/HttpResponses'));
     $configuration = new Configuration();
     $configuration->setUrlToValidate('http://example.com/foo"bar');
     $configuration->setHttpClient($this->getHttpClient());
     $configuration->setContentToValidate(file_get_contents($this->getFixturesDataPath() . '/WebResourceContent/rootWebResource.html'));
     $this->wrapper = $this->getNewCssValidatorWrapper();
     $this->wrapper->setConfiguration($configuration);
 }
 public function setUp()
 {
     $this->setTestFixturePath(__CLASS__);
     $this->setHttpFixtures($this->getHttpFixtures($this->getFixturesDataPath() . '/HttpResponses'));
     $configuration = new Configuration();
     $configuration->setUrlToValidate('http://example.com/');
     $configuration->setHttpClient($this->getHttpClient());
     $this->wrapper = $this->getNewCssValidatorWrapper();
     $this->wrapper->setConfiguration($configuration);
     $this->wrapper->setCssValidatorRawOutput($this->getFixture('domains-to-ignore.txt'));
 }
 public function setUp()
 {
     $this->setTestFixturePath(__CLASS__);
     $this->setHttpFixtures($this->getHttpFixtures($this->getFixturesDataPath() . '/HttpResponses'));
     $configuration = new Configuration();
     $configuration->setUrlToValidate('http://example.com/');
     $configuration->setHttpClient($this->getHttpClient());
     $this->wrapper = $this->getNewCssValidatorWrapper();
     $this->wrapper->setConfiguration($configuration);
     $this->wrapper->enableDeferToParentIfNoRawOutput();
     $this->wrapper->setCssValidatorRawOutput($this->getFixture('no-messages.txt'));
 }
 public function setUp()
 {
     $this->setTestFixturePath(__CLASS__);
     $this->setHttpFixtures($this->getHttpFixtures($this->getFixturesDataPath($this->getName()) . '/HttpResponses'));
     $configuration = new Configuration();
     $configuration->setUrlToValidate('http://grantammons.me/');
     $configuration->setHttpClient($this->getHttpClient());
     $configuration->setContentToValidate(file_get_contents($this->getFixturesDataPath() . '/WebResourceContent/rootWebResource.html'));
     $this->wrapper = $this->getNewCssValidatorWrapper();
     $this->wrapper->setConfiguration($configuration);
     $this->wrapper->setCssValidatorRawOutput($this->getFixture('no-messages.txt'));
     $this->wrapper->enableDeferToParentIfNoRawOutput();
 }
 public function setUp()
 {
     $this->setTestFixturePath(get_class($this));
     $this->setHttpFixtures($this->getHttpFixtures($this->getFixturesDataPath() . '/HttpResponses'));
     $cookieJar = new CookieJar();
     foreach ($this->getCookies() as $cookieData) {
         $cookieJar->setCookie(new SetCookie($cookieData));
     }
     $this->getHttpClient()->getEmitter()->attach(new HttpCookieSubscriber($cookieJar));
     $configuration = new Configuration();
     $configuration->setUrlToValidate('http://example.com/');
     $configuration->setHttpClient($this->getHttpClient());
     $this->wrapper = $this->getNewCssValidatorWrapper();
     $this->wrapper->setConfiguration($configuration);
     $this->wrapper->enableDeferToParentIfNoRawOutput();
     $this->wrapper->setCssValidatorRawOutput($this->getFixture('no-messages.txt'));
     $this->wrapper->validate();
 }
Exemplo n.º 12
0
 /**
  * 
  * @param array $configurationValues
  * @return \webignition\CssValidatorWrapper\Wrapper
  * @throws \InvalidArgumentException
  */
 public function createConfiguration($configurationValues)
 {
     if (!is_array($configurationValues) || empty($configurationValues)) {
         throw new \InvalidArgumentException('A non-empty array of configuration values must be passed to create configuration', 2);
     }
     if (!isset($configurationValues['url-to-validate'])) {
         throw new \InvalidArgumentException('Configruation value "url-to-validate" not set', self::INVALID_ARGUMENT_EXCEPTION_URL_TO_VALIDATE_NOT_SET);
     }
     $configuration = new Configuration();
     $configuration->setUrlToValidate($configurationValues['url-to-validate']);
     if (isset($configurationValues['java-executable-path'])) {
         $configuration->setJavaExecutablePath($configurationValues['java-executable-path']);
     }
     if (isset($configurationValues['css-validator-jar-path'])) {
         $configuration->setCssValidatorJarPath($configurationValues['css-validator-jar-path']);
     }
     if (isset($configurationValues['vendor-extension-severity-level'])) {
         $configuration->setVendorExtensionSeverityLevel($configurationValues['vendor-extension-severity-level']);
     }
     if (isset($configurationValues['flags']) && is_array($configurationValues['flags'])) {
         foreach ($configurationValues['flags'] as $flag) {
             $configuration->setFlag($flag);
         }
     }
     if (isset($configurationValues['domains-to-ignore']) && is_array($configurationValues['domains-to-ignore'])) {
         $configuration->setDomainsToIgnore($configurationValues['domains-to-ignore']);
     }
     if (isset($configurationValues['http-client']) && $configurationValues['http-client'] instanceof HttpClient) {
         $configuration->setHttpClient($configurationValues['http-client']);
     }
     if (isset($configurationValues['content-to-validate'])) {
         $configuration->setContentToValidate($configurationValues['content-to-validate']);
     }
     $this->setConfiguration($configuration);
     return $this;
 }
 public function testSetInvalidValueThrowsInvalidArgumentException()
 {
     $this->setExpectedException('InvalidArgumentException');
     $configuration = new Configuration();
     $configuration->setVendorExtensionSeverityLevel('foo');
 }
 public function testFalseWhenNoUrlToValidate()
 {
     $configuration = new Configuration();
     $this->assertFalse($configuration->setUrlToValidate('')->hasUrlToValidate());
 }
 public function testWithDefaultValuesAndUrlToTest()
 {
     $configuration = new Configuration();
     $this->assertEquals('java -jar css-validator.jar -output ucn -vextwarning true "http://example.com/" 2>&1', $configuration->setUrlToValidate('http://example.com/')->getExecutableCommand());
 }
 public function testHasContentToValidateIsTrueWhenContentIsSet()
 {
     $configuration = new Configuration();
     $configuration->setContentToValidate('foo');
     $this->assertTrue($configuration->hasContentToValidate());
 }
 /**
  * 
  * @return string
  */
 public function getRootWebResourceUrl()
 {
     return $this->sourceConfiguration->getUrlToValidate();
 }
 public function testSetInvalidValueThrowsInvalidArgumentException()
 {
     $this->setExpectedException('InvalidArgumentException');
     $configuration = new Configuration();
     $configuration->setFlag('foo');
 }