コード例 #1
0
 public function testInvokeWithRowClassCallback()
 {
     $rowClassCallback = function ($columns) {
         static $counter = 0;
         if ($counter++) {
             return "{$columns['column1']}+{$columns['column2']}";
         } else {
             return '';
         }
     };
     $this->_escapeHtml->expects($this->exactly(4))->method('__invoke')->will($this->returnArgument(0));
     $table = $this->getMockBuilder($this->_getHelperClass())->setConstructorArgs(array($this->_escapeHtml, $this->_htmlTag, $this->_consoleUrl, $this->_dateFormat))->setMethods(array('sortableHeader', 'row'))->getMock();
     $table->expects($this->never())->method('sortableHeader');
     $table->expects($this->at(0))->method('row')->with($this->_headers, true, array(), null)->will($this->returnCallback(array($this, 'mockRow')));
     $table->expects($this->at(1))->method('row')->with(array('column1' => 'value1a', 'column2' => 'value2a'), false, array(), '')->will($this->returnCallback(array($this, 'mockRow')));
     $table->expects($this->at(2))->method('row')->with(array('column1' => 'value1b', 'column2' => 'value2b'), false, array(), 'value1b+value2b')->will($this->returnCallback(array($this, 'mockRow')));
     $this->assertEquals($this->_expected, $table($this->_data, $this->_headers, array(), array(), array(), $rowClassCallback));
 }