Skip to content
This repository

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

Merged
merged 2 commits into from almost 2 years ago

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 July 23, 2012
Ralph Schindler ralphschindler closed this July 23, 2012
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
@@ -288,4 +288,26 @@ public function __set($name, $value)
288 288
     {
289 289
         $this->offsetSet($name, $value);
290 290
     }
  291
+
  292
+    /**
  293
+     * __isset
  294
+     *
  295
+     * @param  string $name
  296
+     * @return boolean
  297
+     */
  298
+    public function __isset($name)
  299
+    {
  300
+        return $this->offsetExists($name);
  301
+    }
  302
+
  303
+    /**
  304
+     * __unset
  305
+     *
  306
+     * @param  string $name
  307
+     * @return void
  308
+     */
  309
+    public function __unset($name)
  310
+    {
  311
+        $this->offsetUnset($name);
  312
+    }
291 313
 }
49  tests/Zend/Db/RowGateway/RowGatewayTest.php
@@ -53,4 +53,53 @@ public function test__set()
53 53
         $this->assertEquals('test', $row['testColumn']);
54 54
     }
55 55
 
  56
+    public function test__isset()
  57
+    {
  58
+        // Test isset before and after assigning to a property:
  59
+        $row = new RowGateway('id', 'fake', $this->mockAdapter);
  60
+        $this->assertFalse(isset($row->foo));
  61
+        $row->foo = 'bar';
  62
+        $this->assertTrue(isset($row->foo));
  63
+
  64
+        // Test isset before and after assigning to an index:
  65
+        $row = new RowGateway('id', 'fake', $this->mockAdapter);
  66
+        $this->assertFalse(isset($row->foo));
  67
+        $row['foo'] = 'bar';
  68
+        $this->assertTrue(isset($row->foo));
  69
+    }
  70
+
  71
+    public function testOffsetExists()
  72
+    {
  73
+        // Test isset before and after assigning to a property:
  74
+        $row = new RowGateway('id', 'fake', $this->mockAdapter);
  75
+        $this->assertFalse(isset($row['foo']));
  76
+        $row->foo = 'bar';
  77
+        $this->assertTrue(isset($row['foo']));
  78
+
  79
+        // Test isset before and after assigning to an index:
  80
+        $row = new RowGateway('id', 'fake', $this->mockAdapter);
  81
+        $this->assertFalse(isset($row['foo']));
  82
+        $row['foo'] = 'bar';
  83
+        $this->assertTrue(isset($row['foo']));
  84
+    }
  85
+
  86
+    public function test__unset()
  87
+    {
  88
+        $row = new RowGateway('id', 'fake', $this->mockAdapter);
  89
+        $row->foo = 'bar';
  90
+        $this->assertEquals('bar', $row->foo);
  91
+        unset($row->foo);
  92
+        $this->assertEmpty($row->foo);
  93
+        $this->assertEmpty($row['foo']);
  94
+    }
  95
+
  96
+    public function testOffsetUnset()
  97
+    {
  98
+        $row = new RowGateway('id', 'fake', $this->mockAdapter);
  99
+        $row['foo'] = 'bar';
  100
+        $this->assertEquals('bar', $row['foo']);
  101
+        unset($row['foo']);
  102
+        $this->assertEmpty($row->foo);
  103
+        $this->assertEmpty($row['foo']);
  104
+    }
56 105
 }
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.