浏览代码

Merge pull request #2680 from WouterJ/patch-3

Add a way to see if a tab group is open
Thomas 10 年之前
父节点
当前提交
4cd443ea68
共有 2 个文件被更改,包括 21 次插入0 次删除
  1. 10 0
      Mapper/BaseGroupedMapper.php
  2. 11 0
      Tests/Mapper/BaseGroupedMapperTest.php

+ 10 - 0
Mapper/BaseGroupedMapper.php

@@ -219,6 +219,16 @@ abstract class BaseGroupedMapper extends BaseMapper
 
         return $this;
     }
+    
+    /**
+     * Returns a boolean indicating if there is an open tab at the moment.
+     * 
+     * @return boolean
+     */
+    public function hasOpenTab()
+    {
+        return null !== $this->currentTab;
+    }
 
     /**
      * Add the fieldname to the current group

+ 11 - 0
Tests/Mapper/BaseGroupedMapperTest.php

@@ -132,6 +132,17 @@ class BaseGroupedMapperTest extends \PHPUnit_Framework_TestCase
         $this->baseGroupedMapper->tab('fooTab');
         $this->baseGroupedMapper->tab('barTab');
     }
+    
+    public function testHasOpenTab()
+    {
+        $this->assertFalse($this->baseGroupedMapper->hasOpenTab(), '->hasOpenTab() returns false when there are no tabs');
+        
+        $this->baseGroupedMapper->tab('fooTab');
+        $this->assertTrue($this->baseGroupedMapper->hasOpenTab(), '->hasOpenTab() returns true when there is an open tab');
+        
+        $this->baseGroupedMapper->end();
+        $this->assertFalse($this->baseGroupedMapper->hasOpenTab(), '->hasOpenTab() returns false when all tabs are closed');
+    }
 
     /**
      * @expectedException        RuntimeException