public function testStripKeys() { $this->assertSame([1, 2], ArrayUtils::stripKeys(["one" => 1, "two" => 2])); $this->assertSame([1, [2], 3], ArrayUtils::stripKeys(["one" => 1, "two" => ["three" => 2], "four" => 3])); $this->assertNotEquals([["inner" => 1]], ArrayUtils::stripKeys([["inner" => 1]])); $this->assertSame([[1]], ArrayUtils::stripKeys([["inner" => 1]])); $this->setExpectedException('PHPUnit_Framework_Error'); ArrayUtils::stripKeys("not an array"); }
/** * Strips keys and removes slashes off supplied data and replaces current result * with it. * @param array $table multi-dimensional table-like array * @return DataScript self * @see setOutput() */ protected final function setOutputTable($table) { $table = ArrayUtils::stripKeys($table); foreach ($table as &$row) { foreach ($row as &$cell) { if (is_string($cell)) { $cell = stripslashes($cell); } } } $this->setOutput($table); return $this; }