Browse Source

Add tests for array properties.

Mark Story 10 years ago
parent
commit
1f8aa5fb61
1 changed files with 27 additions and 0 deletions
  1. 27 0
      tests/TestCase/View/ViewBuilderTest.php

+ 27 - 0
tests/TestCase/View/ViewBuilderTest.php

@@ -43,6 +43,19 @@ class ViewBuilderTest extends TestCase
     }
 
     /**
+     * data provider for array properties.
+     *
+     * @return array
+     */
+    public function arrayPropertyProvider()
+    {
+        return [
+            ['helpers', ['Html', 'Form']],
+            ['options', ['key' => 'value']],
+        ];
+    }
+
+    /**
      * Test string property accessor/mutator methods.
      *
      * @dataProvider stringPropertyProvider
@@ -55,4 +68,18 @@ class ViewBuilderTest extends TestCase
         $this->assertSame($builder, $builder->{$property}($value), 'Setter returns this');
         $this->assertSame($value, $builder->{$property}(), 'Getter gets value.');
     }
+
+    /**
+     * Test array property accessor/mutator methods.
+     *
+     * @dataProvider arrayPropertyProvider
+     * @return void
+     */
+    public function testArrayProperties($property, $value)
+    {
+        $builder = new ViewBuilder();
+        $this->assertSame([], $builder->{$property}(), 'Default value should be empty list');
+        $this->assertSame($builder, $builder->{$property}($value), 'Setter returns this');
+        $this->assertSame($value, $builder->{$property}(), 'Getter gets value.');
+    }
 }