예제 #1
0
 /**
  * testFormattingNullValues method
  *
  * @return void
  */
 public function testFormatNullValues()
 {
     $data = [['Person' => ['first_name' => 'Nate', 'last_name' => 'Abele', 'city' => 'Boston', 'state' => 'MA', 'something' => '42']], ['Person' => ['first_name' => 'Larry', 'last_name' => 'Masters', 'city' => 'Boondock', 'state' => 'TN', 'something' => null]], ['Person' => ['first_name' => 'Garrett', 'last_name' => 'Woodworth', 'city' => 'Venice Beach', 'state' => 'CA', 'something' => null]]];
     $result = Hash::format($data, ['{n}.Person.something'], '%s');
     $expected = ['42', '', ''];
     $this->assertEquals($expected, $result);
     $result = Hash::format($data, ['{n}.Person.city', '{n}.Person.something'], '%s, %s');
     $expected = ['Boston, 42', 'Boondock, ', 'Venice Beach, '];
     $this->assertEquals($expected, $result);
 }