/** * UtilityTest::testLogicalAnd() * * @covers ::logicalAnd * @return void */ public function testLogicalAnd() { $array = ['a' => 1, 'b' => 1, 'c' => 0, 'd' => 1]; $is = Utility::logicalAnd($array); $this->assertFalse($is); $array = ['a' => 1, 'b' => 1, 'c' => 1, 'd' => 1]; $is = Utility::logicalAnd($array); $this->assertTrue($is); }
/** * On non-transaction db connections it will return a deep array of bools instead of bool. * So we need to call this method inside the modified saveAll() method to return the expected single bool there, too. * * @param array * @return bool * @deprecated Not sure this is useful for CakePHP 3.0 */ public static function isValidSaveAll($array) { if (empty($array)) { return false; } $ret = true; foreach ($array as $key => $val) { if (is_array($val)) { $ret = $ret & Utility::logicalAnd($val); } else { $ret = $ret & $val; } } return (bool) $ret; }