Example #1
0
 /**
  * Method to test walk()
  *
  * @return  void
  *
  * @covers  Windwalker\Data\DataSet::walk
  */
 public function testWalk()
 {
     $this->instance->walk(function (&$data, $key, $userdata) {
         $data->foo = $userdata . ':' . $key;
     }, 'prefix');
     $this->assertEquals(array('prefix:0', 'prefix:1'), $this->instance->foo);
 }
 /**
  * testKrsort
  *
  * @return  void
  *
  * @covers  Windwalker\Data\DataSet::krsort
  */
 public function testKrsort()
 {
     $dataset = new DataSet();
     $dataset[1] = array('flower' => 'sakura');
     $dataset[2] = array('flower' => 'rose');
     $dataset[0] = array('flower' => 'sunflower');
     $dataset->krsort();
     $this->assertEquals(array('rose', 'sakura', 'sunflower'), array_values($dataset->flower));
     $dataset = new DataSet();
     $dataset['001'] = array('flower' => 'sakura');
     $dataset['2'] = array('flower' => 'rose');
     $dataset['00030'] = array('flower' => 'sunflower');
     $dataset->krsort(SORT_STRING);
     $this->assertEquals(array('rose', 'sakura', 'sunflower'), array_values($dataset->flower));
 }