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

Commit

Permalink
Merge branch 'cs/remove-underscores' of https://github.com/arse/zf2 i…
Browse files Browse the repository at this point in the history
…nto feature/protected-underscores

Conflicts:
	library/Zend/Console/Getopt.php
  • Loading branch information
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 42 deletions.
34 changes: 16 additions & 18 deletions src/Storage/Capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Capabilities
*
* @var null|boolean
*/
protected $_expiredRead;
protected $expiredRead;

/**
* Max. key length
Expand All @@ -61,7 +61,7 @@ class Capabilities
*
* @var null|int
*/
protected $_maxKeyLength;
protected $maxKeyLength;

/**
* Min. TTL (0 means items never expire)
Expand All @@ -71,7 +71,7 @@ class Capabilities
*
* @var null|int
*/
protected $_minTtl;
protected $minTtl;

/**
* Max. TTL (0 means infinite)
Expand All @@ -81,7 +81,7 @@ class Capabilities
*
* @var null|int
*/
protected $_maxTtl;
protected $maxTtl;

/**
* Namespace is prefix
Expand All @@ -91,7 +91,7 @@ class Capabilities
*
* @var null|boolean
*/
protected $_namespaceIsPrefix;
protected $namespaceIsPrefix;

/**
* Namespace separator
Expand All @@ -101,7 +101,7 @@ class Capabilities
*
* @var null|string
*/
protected $_namespaceSeparator;
protected $namespaceSeparator;

/**
* Static ttl
Expand All @@ -111,7 +111,7 @@ class Capabilities
*
* @var null|boolean
*/
protected $_staticTtl;
protected $staticTtl;

/**
* Supported datatypes
Expand All @@ -121,7 +121,7 @@ class Capabilities
*
* @var null|array
*/
protected $_supportedDatatypes;
protected $supportedDatatypes;

/**
* Supported metdata
Expand All @@ -131,7 +131,7 @@ class Capabilities
*
* @var null|array
*/
protected $_supportedMetadata;
protected $supportedMetadata;

/**
* TTL precision
Expand All @@ -141,7 +141,7 @@ class Capabilities
*
* @var null|int
*/
protected $_ttlPrecision;
protected $ttlPrecision;

/**
* Use request time
Expand All @@ -151,7 +151,7 @@ class Capabilities
*
* @var null|boolean
*/
protected $_useRequestTime;
protected $useRequestTime;

/**
* Constructor
Expand Down Expand Up @@ -495,17 +495,16 @@ public function setNamespaceSeparator(stdClass $marker, $separator)
/**
* Get a capability
*
* @param string $name
* @param string $property
* @param mixed $default
* @return mixed
*/
protected function getCapability($name, $default = null)
protected function getCapability($property, $default = null)
{
$property = '_' . $name;
if ($this->$property !== null) {
return $this->$property;
} elseif ($this->baseCapabilities) {
$getMethod = 'get' . $name;
$getMethod = 'get' . $property;
return $this->baseCapabilities->$getMethod();
}
return $default;
Expand All @@ -520,20 +519,19 @@ protected function getCapability($name, $default = null)
* @return Capabilities Fluent interface
* @throws Exception\InvalidArgumentException
*/
protected function setCapability(stdClass $marker, $name, $value)
protected function setCapability(stdClass $marker, $property, $value)
{
if ($this->marker !== $marker) {
throw new Exception\InvalidArgumentException('Invalid marker');
}

$property = '_' . $name;
if ($this->$property !== $value) {
$this->$property = $value;

// trigger event
if ($this->storage instanceof EventsCapableInterface) {
$this->storage->getEventManager()->trigger('capability', $this->storage, new ArrayObject(array(
$name => $value
$property => $value
)));
}
}
Expand Down
48 changes: 24 additions & 24 deletions test/Storage/Adapter/AbstractAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -377,13 +377,13 @@ public function testGetMetadatas()
$i = 0;
foreach ($items as $k => $v) {
$this->_storage->expects($this->at($i++))
$this->storage->expects($this->at($i++))
->method('getMetadata')
->with($this->equalTo($k), $this->equalTo($options))
->will($this->returnValue($v));
}
$rs = $this->_storage->getMetadatas(array_keys($items), $options);
$rs = $this->storage->getMetadatas(array_keys($items), $options);
// remove missing items from array to test
$expected = $items;
Expand All @@ -404,12 +404,12 @@ public function testSetItems()
'key2' => 'value2'
);
$this->_storage->expects($this->exactly(count($items)))
$this->storage->expects($this->exactly(count($items)))
->method('setItem')
->with($this->stringContains('key'), $this->stringContains('value'), $this->equalTo($options))
->will($this->returnValue(true));
$this->assertTrue($this->_storage->setItems($items, $options));
$this->assertTrue($this->storage->setItems($items, $options));
}
public function testSetItemsFail()
Expand All @@ -421,12 +421,12 @@ public function testSetItemsFail()
'key3' => 'value3',
);
$this->_storage->expects($this->exactly(count($items)))
$this->storage->expects($this->exactly(count($items)))
->method('setItem')
->with($this->stringContains('key'), $this->stringContains('value'), $this->equalTo($options))
->will($this->returnValue(false));
$this->assertFalse($this->_storage->setItems($items, $options));
$this->assertFalse($this->storage->setItems($items, $options));
}
public function testAddItems()
Expand All @@ -438,16 +438,16 @@ public function testAddItems()
);
// add -> has -> get -> set
$this->_storage->expects($this->exactly(count($items)))
$this->storage->expects($this->exactly(count($items)))
->method('getItem')
->with($this->stringContains('key'), $this->equalTo($options))
->will($this->returnValue(false));
$this->_storage->expects($this->exactly(count($items)))
$this->storage->expects($this->exactly(count($items)))
->method('setItem')
->with($this->stringContains('key'), $this->stringContains('value'), $this->equalTo($options))
->will($this->returnValue(true));
$this->assertTrue($this->_storage->addItems($items, $options));
$this->assertTrue($this->storage->addItems($items, $options));
}
public function testAddItemsFail()
Expand All @@ -460,16 +460,16 @@ public function testAddItemsFail()
);
// add -> has -> get -> set
$this->_storage->expects($this->exactly(count($items)))
$this->storage->expects($this->exactly(count($items)))
->method('getItem')
->with($this->stringContains('key'), $this->equalTo($options))
->will($this->returnValue(false));
$this->_storage->expects($this->exactly(count($items)))
$this->storage->expects($this->exactly(count($items)))
->method('setItem')
->with($this->stringContains('key'), $this->stringContains('value'), $this->equalTo($options))
->will($this->returnValue(false));
$this->assertFalse($this->_storage->addItems($items, $options));
$this->assertFalse($this->storage->addItems($items, $options));
}
public function testReplaceItems()
Expand All @@ -481,16 +481,16 @@ public function testReplaceItems()
);
// replace -> has -> get -> set
$this->_storage->expects($this->exactly(count($items)))
$this->storage->expects($this->exactly(count($items)))
->method('getItem')
->with($this->stringContains('key'), $this->equalTo($options))
->will($this->returnValue(true));
$this->_storage->expects($this->exactly(count($items)))
$this->storage->expects($this->exactly(count($items)))
->method('setItem')
->with($this->stringContains('key'), $this->stringContains('value'), $this->equalTo($options))
->will($this->returnValue(true));
$this->assertTrue($this->_storage->replaceItems($items, $options));
$this->assertTrue($this->storage->replaceItems($items, $options));
}
public function testReplaceItemsFail()
Expand All @@ -503,16 +503,16 @@ public function testReplaceItemsFail()
);
// replace -> has -> get -> set
$this->_storage->expects($this->exactly(count($items)))
$this->storage->expects($this->exactly(count($items)))
->method('getItem')
->with($this->stringContains('key'), $this->equalTo($options))
->will($this->returnValue(true));
$this->_storage->expects($this->exactly(count($items)))
$this->storage->expects($this->exactly(count($items)))
->method('setItem')
->with($this->stringContains('key'), $this->stringContains('value'), $this->equalTo($options))
->will($this->returnValue(false));
$this->assertFalse($this->_storage->replaceItems($items, $options));
$this->assertFalse($this->storage->replaceItems($items, $options));
}
public function testRemoveItems()
Expand All @@ -521,34 +521,34 @@ public function testRemoveItems()
$keys = array('key1', 'key2');
foreach ($keys as $i => $key) {
$this->_storage->expects($this->at($i))
$this->storage->expects($this->at($i))
->method('removeItem')
->with($this->equalTo($key), $this->equalTo($options))
->will($this->returnValue(true));
}
$this->assertTrue($this->_storage->removeItems($keys, $options));
$this->assertTrue($this->storage->removeItems($keys, $options));
}
public function testRemoveItemsFail()
{
$options = array('ttl' => 123);
$items = array('key1', 'key2', 'key3');
$this->_storage->expects($this->at(0))
$this->storage->expects($this->at(0))
->method('removeItem')
->with($this->equalTo('key1'), $this->equalTo($options))
->will($this->returnValue(true));
$this->_storage->expects($this->at(1))
$this->storage->expects($this->at(1))
->method('removeItem')
->with($this->equalTo('key2'), $this->equalTo($options))
->will($this->returnValue(false)); // -> fail
$this->_storage->expects($this->at(2))
$this->storage->expects($this->at(2))
->method('removeItem')
->with($this->equalTo('key3'), $this->equalTo($options))
->will($this->returnValue(true));
$this->assertFalse($this->_storage->removeItems($items, $options));
$this->assertFalse($this->storage->removeItems($items, $options));
}
*/
// TODO: incrementItem[s] + decrementItem[s]
Expand Down

0 comments on commit a7a7974

Please sign in to comment.