public function testfieldsInDbVsMyArray() { $log_file = fopen("/var/www/jimfuqua/tutor/logs/CT testfieldsInDbVsMyArray", "w"); // get a list of fields in the db $this->testbuildArray(); // reset myArray to origninal values. $classInstance = new tutor\src\CompletedClass(); $result = $classInstance->insertRecord($this->myArray); $results = $classInstance->getLastDbEntry(); $this->assertTrue(count($results) === count($this->myArray)); // Put all of the column names from the returned row in an array. $dbKeys = []; $i = 0; foreach ($results as $key => $value) { $dbKeys[$i] = $key; $i++; } $v = var_export($dbKeys, true); $string = "\n" . __LINE__ . ' $dbKeys = ' . $v . "\n"; fwrite($log_file, $string); $i = 0; foreach ($this->myArray as $key => $value) { $myArrayKeys[$i] = $key; $i++; } $v = var_export($myArrayKeys, true); $string = "\n" . __LINE__ . ' $myArrayKeys = ' . $v . "\n"; fwrite($log_file, $string); $num_columns = $i; $i = 0; // Compare the two arrays key by key. for ($i < $num_columns; $i++;) { $this->assertTrue($dbKeys[$i] === $myArrayKeys[$i], "{$i}.' '.{$dbKeys[$i]} === {$myArrayKeys[$i]}"); } }