gradido/community_server/tests/Fixture/BaseTestFixture.php
2021-04-14 14:17:56 +00:00

40 lines
1.2 KiB
PHP

<?php
namespace App\Test\Fixture;
use Cake\TestSuite\Fixture\TestFixture;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
class BaseTestFixture extends TestFixture
{
// after copy from sql export, replace all hex values to hex strings with regExp (z.B. within Netbeans)
<<<<<<< HEAD
// ''([0-9a-f]*) => '$1'
=======
// 0x([0-9a-f]*) => '$1'
>>>>>>> 33d751edaa339bca5a33ee873d2f00453dd0545a
protected function sqlEntrysToRecords($sql_entries, $fields) {
$field_array_keys = array_keys($fields);
$records = [];
foreach($sql_entries as $sql_entry) {
$record = [];
foreach($sql_entry as $i => $value) {
$field = $field_array_keys[$i];
if($fields[$field]['type'] == 'binary') {
if(is_string($value)) {
$record[$field] = hex2bin($value);
}
} else {
$record[$field] = $value;
}
}
$records[] = $record;
}
return $records;
}
}