Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Resolving ZF2-406: missing __isset / __unset in AbstractRowGateway. #1911

Merged
merged 2 commits into from

3 participants

Demian Katz Don't Add Me To Your Organization a.k.a The Travis Bot Ralph Schindler
Demian Katz

No description provided.

Don't Add Me To Your Organization a.k.a The Travis Bot

This pull request passes (merged fe99236 into 7e444f8).

Don't Add Me To Your Organization a.k.a The Travis Bot

This pull request passes (merged aa57468 into 1649232).

Ralph Schindler ralphschindler merged commit aa57468 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
22 library/Zend/Db/RowGateway/AbstractRowGateway.php
View
@@ -288,4 +288,26 @@ public function __set($name, $value)
{
$this->offsetSet($name, $value);
}
+
+ /**
+ * __isset
+ *
+ * @param string $name
+ * @return boolean
+ */
+ public function __isset($name)
+ {
+ return $this->offsetExists($name);
+ }
+
+ /**
+ * __unset
+ *
+ * @param string $name
+ * @return void
+ */
+ public function __unset($name)
+ {
+ $this->offsetUnset($name);
+ }
}
49 tests/Zend/Db/RowGateway/RowGatewayTest.php
View
@@ -53,4 +53,53 @@ public function test__set()
$this->assertEquals('test', $row['testColumn']);
}
+ public function test__isset()
+ {
+ // Test isset before and after assigning to a property:
+ $row = new RowGateway('id', 'fake', $this->mockAdapter);
+ $this->assertFalse(isset($row->foo));
+ $row->foo = 'bar';
+ $this->assertTrue(isset($row->foo));
+
+ // Test isset before and after assigning to an index:
+ $row = new RowGateway('id', 'fake', $this->mockAdapter);
+ $this->assertFalse(isset($row->foo));
+ $row['foo'] = 'bar';
+ $this->assertTrue(isset($row->foo));
+ }
+
+ public function testOffsetExists()
+ {
+ // Test isset before and after assigning to a property:
+ $row = new RowGateway('id', 'fake', $this->mockAdapter);
+ $this->assertFalse(isset($row['foo']));
+ $row->foo = 'bar';
+ $this->assertTrue(isset($row['foo']));
+
+ // Test isset before and after assigning to an index:
+ $row = new RowGateway('id', 'fake', $this->mockAdapter);
+ $this->assertFalse(isset($row['foo']));
+ $row['foo'] = 'bar';
+ $this->assertTrue(isset($row['foo']));
+ }
+
+ public function test__unset()
+ {
+ $row = new RowGateway('id', 'fake', $this->mockAdapter);
+ $row->foo = 'bar';
+ $this->assertEquals('bar', $row->foo);
+ unset($row->foo);
+ $this->assertEmpty($row->foo);
+ $this->assertEmpty($row['foo']);
+ }
+
+ public function testOffsetUnset()
+ {
+ $row = new RowGateway('id', 'fake', $this->mockAdapter);
+ $row['foo'] = 'bar';
+ $this->assertEquals('bar', $row['foo']);
+ unset($row['foo']);
+ $this->assertEmpty($row->foo);
+ $this->assertEmpty($row['foo']);
+ }
}
Something went wrong with that request. Please try again.