public function testTotalItems()
 {
     $list = GroupedList::create(ArrayList::create(array(ArrayData::create(array('Name' => 'AAA', 'Number' => '111')), ArrayData::create(array('Name' => 'BBB', 'Number' => '111')), ArrayData::create(array('Name' => 'AAA', 'Number' => '222')), ArrayData::create(array('Name' => 'BBB', 'Number' => '111')))));
     $this->assertEquals(4, $list->TotalItems());
 }
 public function TestLoopCall()
 {
     $this->testLoopCalls++;
     return ArrayList::create(array(ArrayData::create(array('Message' => 'One')), ArrayData::create(array('Message' => 'Two'))));
 }
 /**
  * Test that circular dependencies throw an exception
  */
 public function testGridFieldCustomFragmentsCircularDependencyThrowsException()
 {
     $config = GridFieldConfig::create()->addComponents(new GridFieldTest_HTMLFragments(array("level-one" => "first")), new GridFieldTest_HTMLFragments(array("before" => "<div>\$DefineFragment(level-one)</div>")), new GridFieldTest_HTMLFragments(array("level-one" => "<strong>\$DefineFragment(level-two)</strong>")), new GridFieldTest_HTMLFragments(array("level-two" => "<blink>\$DefineFragment(level-one)</blink>")));
     $field = new GridField('testfield', 'testfield', ArrayList::create(), $config);
     $form = new Form(new Controller(), 'testform', new FieldList(array($field)), new FieldList());
     $this->setExpectedException('LogicException');
     $field->FieldHolder();
 }
 /**
  * Note that, in the current implementation, the filtered list will be an ArrayList, but this may change in a
  * future implementation.
  * @see Filterable::filterByCallback()
  *
  * @example $list = $list->filterByCallback(function($item, $list) { return $item->Age == 9; })
  * @param callable $callback
  * @return ArrayList (this may change in future implementations)
  */
 public function filterByCallback($callback)
 {
     if (!is_callable($callback)) {
         throw new LogicException(sprintf("SS_Filterable::filterByCallback() passed callback must be callable, '%s' given", gettype($callback)));
     }
     $output = ArrayList::create();
     foreach ($this->list as $item) {
         if (call_user_func($callback, $item, $this->list)) {
             $output->push($item);
         }
     }
     return $output;
 }