-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
96 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of CodeIgniter Queue. | ||
* | ||
* (c) CodeIgniter Foundation <[email protected]> | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Tests\Support\Constraints; | ||
|
||
use CodeIgniter\Test\Constraints\SeeInDatabase; | ||
|
||
class SeeInDatabaseExtended extends SeeInDatabase | ||
{ | ||
/** | ||
* Gets a string representation of the constraint | ||
* | ||
* @param int $options | ||
*/ | ||
public function toString(bool $exportObjects = false, $options = 0): string | ||
{ | ||
$this->data = array_combine( | ||
array_map(fn ($key) => $this->extractFieldName($key), array_keys($this->data)), | ||
$this->data | ||
); | ||
|
||
return parent::toString($exportObjects, $options); | ||
} | ||
|
||
/** | ||
* Extract field name from complex key | ||
*/ | ||
protected function extractFieldName(string $input): string | ||
{ | ||
$pattern = '/CONVERT\(\s*\w+,\s*(\w+)\s*\)/'; | ||
|
||
if (preg_match($pattern, $input, $matches)) { | ||
return $matches[1]; | ||
} | ||
|
||
return $input; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters