Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
CS fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Koopzington committed Nov 19, 2016
1 parent 514c91d commit b37b4fd
Show file tree
Hide file tree
Showing 9 changed files with 162 additions and 40 deletions.
2 changes: 2 additions & 0 deletions phpcs.xml
Expand Up @@ -5,4 +5,6 @@
<!-- Paths to check -->
<file>src</file>
<file>test</file>
<!-- Needs to get excluded due it executing code AND declaring symbols -->
<exclude-pattern>/src/ValidatorChain.php</exclude-pattern>
</ruleset>
4 changes: 3 additions & 1 deletion src/SessionManager.php
Expand Up @@ -291,7 +291,9 @@ public function getName()
public function setId($id)
{
if ($this->sessionExists()) {
throw new Exception\RuntimeException('Session has already been started, to change the session ID call regenerateId()');
throw new Exception\RuntimeException(
'Session has already been started, to change the session ID call regenerateId()'
);
}
session_id($id);
return $this;
Expand Down
5 changes: 4 additions & 1 deletion src/Storage/Factory.php
Expand Up @@ -107,7 +107,10 @@ protected static function createArrayStorage($type, $options)
throw new Exception\InvalidArgumentException(sprintf(
'%s expects the "iterator_class" option to be a valid class; received "%s"',
$type,
(is_object($options['iterator_class']) ? get_class($options['iterator_class']) : gettype($options['iterator_class']))
(is_object($options['iterator_class'])
? get_class($options['iterator_class'])
: gettype($options['iterator_class'])
)
));
}
$iteratorClass = $options['iterator_class'];
Expand Down
3 changes: 2 additions & 1 deletion src/compatibility/autoload.php
Expand Up @@ -11,4 +11,5 @@
/**
* Legacy purposes only, to prevent code that references it from breaking.
*/
trigger_error('Polyfill autoload support (file library/Zend/Session/compatibility/autoload.php) is no longer necessary; please remove your require statement referencing this file', E_USER_DEPRECATED);
trigger_error('Polyfill autoload support (file library/Zend/Session/compatibility/autoload.php) is no longer necessary;'
. ' please remove your require statement referencing this file', E_USER_DEPRECATED);
91 changes: 73 additions & 18 deletions test/Config/SessionConfigTest.php
Expand Up @@ -82,7 +82,11 @@ public function testNameAltersIniSetting()

public function testSaveHandlerDefaultsToIniSettings()
{
$this->assertSame(ini_get('session.save_handler'), $this->config->getSaveHandler(), var_export($this->config->toArray(), 1));
$this->assertSame(
ini_get('session.save_handler'),
$this->config->getSaveHandler(),
var_export($this->config->toArray(), 1)
);
}

public function testSaveHandlerIsMutable()
Expand All @@ -99,7 +103,10 @@ public function testSaveHandlerAltersIniSetting()

public function testSettingInvalidSaveHandlerRaisesException()
{
$this->setExpectedException('Zend\Session\Exception\InvalidArgumentException', 'Invalid save handler specified');
$this->setExpectedException(
'Zend\Session\Exception\InvalidArgumentException',
'Invalid save handler specified'
);
$this->config->setPhpSaveHandler('foobar_bogus');
}

Expand All @@ -124,19 +131,28 @@ public function testGcProbabilityAltersIniSetting()

public function testSettingInvalidGcProbabilityRaisesException()
{
$this->setExpectedException('Zend\Session\Exception\InvalidArgumentException', 'Invalid gc_probability; must be numeric');
$this->setExpectedException(
'Zend\Session\Exception\InvalidArgumentException',
'Invalid gc_probability; must be numeric'
);
$this->config->setGcProbability('foobar_bogus');
}

public function testSettingInvalidGcProbabilityRaisesException2()
{
$this->setExpectedException('Zend\Session\Exception\InvalidArgumentException', 'Invalid gc_probability; must be a percentage');
$this->setExpectedException(
'Zend\Session\Exception\InvalidArgumentException',
'Invalid gc_probability; must be a percentage'
);
$this->config->setGcProbability(-1);
}

public function testSettingInvalidGcProbabilityRaisesException3()
{
$this->setExpectedException('Zend\Session\Exception\InvalidArgumentException', 'Invalid gc_probability; must be a percentage');
$this->setExpectedException(
'Zend\Session\Exception\InvalidArgumentException',
'Invalid gc_probability; must be a percentage'
);
$this->config->setGcProbability(101);
}

Expand All @@ -161,13 +177,19 @@ public function testGcDivisorAltersIniSetting()

public function testSettingInvalidGcDivisorRaisesException()
{
$this->setExpectedException('Zend\Session\Exception\InvalidArgumentException', 'Invalid gc_divisor; must be numeric');
$this->setExpectedException(
'Zend\Session\Exception\InvalidArgumentException',
'Invalid gc_divisor; must be numeric'
);
$this->config->setGcDivisor('foobar_bogus');
}

public function testSettingInvalidGcDivisorRaisesException2()
{
$this->setExpectedException('Zend\Session\Exception\InvalidArgumentException', 'Invalid gc_divisor; must be a positive integer');
$this->setExpectedException(
'Zend\Session\Exception\InvalidArgumentException',
'Invalid gc_divisor; must be a positive integer'
);
$this->config->setGcDivisor(-1);
}

Expand All @@ -192,13 +214,19 @@ public function testGcMaxlifetimeAltersIniSetting()

public function testSettingInvalidGcMaxlifetimeRaisesException()
{
$this->setExpectedException('Zend\Session\Exception\InvalidArgumentException', 'Invalid gc_maxlifetime; must be numeric');
$this->setExpectedException(
'Zend\Session\Exception\InvalidArgumentException',
'Invalid gc_maxlifetime; must be numeric'
);
$this->config->setGcMaxlifetime('foobar_bogus');
}

public function testSettingInvalidGcMaxlifetimeRaisesException2()
{
$this->setExpectedException('Zend\Session\Exception\InvalidArgumentException', 'Invalid gc_maxlifetime; must be a positive integer');
$this->setExpectedException(
'Zend\Session\Exception\InvalidArgumentException',
'Invalid gc_maxlifetime; must be a positive integer'
);
$this->config->setGcMaxlifetime(-1);
}

Expand All @@ -225,7 +253,10 @@ public function testSerializeHandlerAltersIniSetting()

public function testSettingInvalidSerializeHandlerRaisesException()
{
$this->setExpectedException('Zend\Session\Exception\InvalidArgumentException', 'Invalid serialize handler specified');
$this->setExpectedException(
'Zend\Session\Exception\InvalidArgumentException',
'Invalid serialize handler specified'
);
$this->config->setSerializeHandler('foobar_bogus');
}

Expand Down Expand Up @@ -256,13 +287,19 @@ public function testCookieLifetimeCanBeZero()

public function testSettingInvalidCookieLifetimeRaisesException()
{
$this->setExpectedException('Zend\Session\Exception\InvalidArgumentException', 'Invalid cookie_lifetime; must be numeric');
$this->setExpectedException(
'Zend\Session\Exception\InvalidArgumentException',
'Invalid cookie_lifetime; must be numeric'
);
$this->config->setCookieLifetime('foobar_bogus');
}

public function testSettingInvalidCookieLifetimeRaisesException2()
{
$this->setExpectedException('Zend\Session\Exception\InvalidArgumentException', 'Invalid cookie_lifetime; must be a positive integer or zero');
$this->setExpectedException(
'Zend\Session\Exception\InvalidArgumentException',
'Invalid cookie_lifetime; must be a positive integer or zero'
);
$this->config->setCookieLifetime(-1);
}

Expand Down Expand Up @@ -330,13 +367,19 @@ public function testCookieDomainAltersIniSetting()

public function testSettingInvalidCookieDomainRaisesException()
{
$this->setExpectedException('Zend\Session\Exception\InvalidArgumentException', 'Invalid cookie domain: must be a string');
$this->setExpectedException(
'Zend\Session\Exception\InvalidArgumentException',
'Invalid cookie domain: must be a string'
);
$this->config->setCookieDomain(24);
}

public function testSettingInvalidCookieDomainRaisesException2()
{
$this->setExpectedException('Zend\Session\Exception\InvalidArgumentException', 'does not match the expected structure for a DNS hostname');
$this->setExpectedException(
'Zend\Session\Exception\InvalidArgumentException',
'does not match the expected structure for a DNS hostname'
);
$this->config->setCookieDomain('D:\\WINDOWS\\System32\\drivers\\etc\\hosts');
}

Expand Down Expand Up @@ -555,7 +598,10 @@ public function testCacheLimiterAltersIniSetting($cacheLimiter)

public function testSettingInvalidCacheLimiterRaisesException()
{
$this->setExpectedException('Zend\Session\Exception\InvalidArgumentException', 'Invalid cache limiter provided');
$this->setExpectedException(
'Zend\Session\Exception\InvalidArgumentException',
'Invalid cache limiter provided'
);
$this->config->setCacheLimiter('foobar_bogus');
}

Expand All @@ -580,13 +626,19 @@ public function testCacheExpireAltersIniSetting()

public function testSettingInvalidCacheExpireRaisesException()
{
$this->setExpectedException('Zend\Session\Exception\InvalidArgumentException', 'Invalid cache_expire; must be numeric');
$this->setExpectedException(
'Zend\Session\Exception\InvalidArgumentException',
'Invalid cache_expire; must be numeric'
);
$this->config->setCacheExpire('foobar_bogus');
}

public function testSettingInvalidCacheExpireRaisesException2()
{
$this->setExpectedException('Zend\Session\Exception\InvalidArgumentException', 'Invalid cache_expire; must be a positive integer');
$this->setExpectedException(
'Zend\Session\Exception\InvalidArgumentException',
'Invalid cache_expire; must be a positive integer'
);
$this->config->setCacheExpire(-1);
}

Expand Down Expand Up @@ -648,7 +700,10 @@ public function testHashFunctionAltersIniSetting($hashFunction)

public function testSettingInvalidHashFunctionRaisesException()
{
$this->setExpectedException('Zend\Session\Exception\InvalidArgumentException', 'Invalid hash function provided');
$this->setExpectedException(
'Zend\Session\Exception\InvalidArgumentException',
'Invalid hash function provided'
);
$this->config->setHashFunction('foobar_bogus');
}

Expand Down
65 changes: 52 additions & 13 deletions test/Config/StandardConfigTest.php
Expand Up @@ -72,19 +72,28 @@ public function testGcProbabilityCanBeSetToZero()

public function testSettingInvalidGcProbabilityRaisesException()
{
$this->setExpectedException('Zend\Session\Exception\InvalidArgumentException', 'Invalid gc_probability; must be numeric');
$this->setExpectedException(
'Zend\Session\Exception\InvalidArgumentException',
'Invalid gc_probability; must be numeric'
);
$this->config->setGcProbability('foobar_bogus');
}

public function testSettingInvalidGcProbabilityRaisesException2()
{
$this->setExpectedException('Zend\Session\Exception\InvalidArgumentException', 'Invalid gc_probability; must be a percentage');
$this->setExpectedException(
'Zend\Session\Exception\InvalidArgumentException',
'Invalid gc_probability; must be a percentage'
);
$this->config->setGcProbability(-1);
}

public function testSettingInvalidGcProbabilityRaisesException3()
{
$this->setExpectedException('Zend\Session\Exception\InvalidArgumentException', 'Invalid gc_probability; must be a percentage');
$this->setExpectedException(
'Zend\Session\Exception\InvalidArgumentException',
'Invalid gc_probability; must be a percentage'
);
$this->config->setGcProbability(101);
}

Expand All @@ -98,13 +107,19 @@ public function testGcDivisorIsMutable()

public function testSettingInvalidGcDivisorRaisesException()
{
$this->setExpectedException('Zend\Session\Exception\InvalidArgumentException', 'Invalid gc_divisor; must be numeric');
$this->setExpectedException(
'Zend\Session\Exception\InvalidArgumentException',
'Invalid gc_divisor; must be numeric'
);
$this->config->setGcDivisor('foobar_bogus');
}

public function testSettingInvalidGcDivisorRaisesException2()
{
$this->setExpectedException('Zend\Session\Exception\InvalidArgumentException', 'Invalid gc_divisor; must be a positive integer');
$this->setExpectedException(
'Zend\Session\Exception\InvalidArgumentException',
'Invalid gc_divisor; must be a positive integer'
);
$this->config->setGcDivisor(-1);
}

Expand All @@ -118,13 +133,19 @@ public function testGcMaxlifetimeIsMutable()

public function testSettingInvalidGcMaxlifetimeRaisesException()
{
$this->setExpectedException('Zend\Session\Exception\InvalidArgumentException', 'Invalid gc_maxlifetime; must be numeric');
$this->setExpectedException(
'Zend\Session\Exception\InvalidArgumentException',
'Invalid gc_maxlifetime; must be numeric'
);
$this->config->setGcMaxlifetime('foobar_bogus');
}

public function testSettingInvalidGcMaxlifetimeRaisesException2()
{
$this->setExpectedException('Zend\Session\Exception\InvalidArgumentException', 'Invalid gc_maxlifetime; must be a positive integer');
$this->setExpectedException(
'Zend\Session\Exception\InvalidArgumentException',
'Invalid gc_maxlifetime; must be a positive integer'
);
$this->config->setGcMaxlifetime(-1);
}

Expand Down Expand Up @@ -153,13 +174,19 @@ public function testCookieLifetimeCanBeZero()

public function testSettingInvalidCookieLifetimeRaisesException()
{
$this->setExpectedException('Zend\Session\Exception\InvalidArgumentException', 'Invalid cookie_lifetime; must be numeric');
$this->setExpectedException(
'Zend\Session\Exception\InvalidArgumentException',
'Invalid cookie_lifetime; must be numeric'
);
$this->config->setCookieLifetime('foobar_bogus');
}

public function testSettingInvalidCookieLifetimeRaisesException2()
{
$this->setExpectedException('Zend\Session\Exception\InvalidArgumentException', 'Invalid cookie_lifetime; must be a positive integer or zero');
$this->setExpectedException(
'Zend\Session\Exception\InvalidArgumentException',
'Invalid cookie_lifetime; must be a positive integer or zero'
);
$this->config->setCookieLifetime(-1);
}

Expand Down Expand Up @@ -205,13 +232,19 @@ public function testCookieDomainCanBeEmpty()

public function testSettingInvalidCookieDomainRaisesException()
{
$this->setExpectedException('Zend\Session\Exception\InvalidArgumentException', 'Invalid cookie domain: must be a string');
$this->setExpectedException(
'Zend\Session\Exception\InvalidArgumentException',
'Invalid cookie domain: must be a string'
);
$this->config->setCookieDomain(24);
}

public function testSettingInvalidCookieDomainRaisesException2()
{
$this->setExpectedException('Zend\Session\Exception\InvalidArgumentException', 'does not match the expected structure for a DNS hostname');
$this->setExpectedException(
'Zend\Session\Exception\InvalidArgumentException',
'does not match the expected structure for a DNS hostname'
);
$this->config->setCookieDomain('D:\\WINDOWS\\System32\\drivers\\etc\\hosts');
}

Expand Down Expand Up @@ -291,13 +324,19 @@ public function testEntropyLengthCanBeZero()

public function testSettingInvalidEntropyLengthRaisesException()
{
$this->setExpectedException('Zend\Session\Exception\InvalidArgumentException', 'Invalid entropy_length; must be numeric');
$this->setExpectedException(
'Zend\Session\Exception\InvalidArgumentException',
'Invalid entropy_length; must be numeric'
);
$this->config->setEntropyLength('foobar_bogus');
}

public function testSettingInvalidEntropyLengthRaisesException2()
{
$this->setExpectedException('Zend\Session\Exception\InvalidArgumentException', 'Invalid entropy_length; must be a positive integer or zero');
$this->setExpectedException(
'Zend\Session\Exception\InvalidArgumentException',
'Invalid entropy_length; must be a positive integer or zero'
);
$this->config->setEntropyLength(-1);
}

Expand Down
6 changes: 5 additions & 1 deletion test/SaveHandler/CacheTest.php
Expand Up @@ -60,7 +60,11 @@ public function testReadWrite()
$this->assertTrue($saveHandler->write($id, serialize($this->testArray)));

$data = unserialize($saveHandler->read($id));
$this->assertEquals($this->testArray, $data, 'Expected ' . var_export($this->testArray, 1) . "\nbut got: " . var_export($data, 1));
$this->assertEquals(
$this->testArray,
$data,
'Expected ' . var_export($this->testArray, 1) . "\nbut got: " . var_export($data, 1)
);
}

public function testReadWriteComplex()
Expand Down

0 comments on commit b37b4fd

Please sign in to comment.