Change Trigger::$table type to use TableName object

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
Maurício Meneghini Fauth 2023-05-27 16:17:21 -03:00
parent a2ed355faf
commit 1582b69591
No known key found for this signature in database
GPG Key ID: 6A16FD38AFC89CC8
3 changed files with 6 additions and 3 deletions

View File

@ -4,6 +4,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Triggers;
use PhpMyAdmin\Dbal\TableName;
use Webmozart\Assert\Assert;
use Webmozart\Assert\InvalidArgumentException;
@ -13,7 +14,7 @@ final class Trigger
public readonly string $name,
public readonly Timing $timing,
public readonly Event $event,
public readonly string $table,
public readonly TableName $table,
public readonly string $statement,
public readonly string $definer,
) {
@ -37,6 +38,8 @@ final class Trigger
$event = Event::tryFrom($event);
Assert::notNull($event);
Assert::string($table);
$table = TableName::tryFromValue($table);
Assert::notNull($table);
Assert::string($statement);
Assert::string($definer);

View File

@ -522,7 +522,7 @@ class Triggers
$oneResult = [];
$oneResult['name'] = $newTrigger->name;
$oneResult['table'] = $newTrigger->table;
$oneResult['table'] = $newTrigger->table->getName();
$oneResult['action_timing'] = $newTrigger->timing->value;
$oneResult['event_manipulation'] = $newTrigger->event->value;
$oneResult['definition'] = $newTrigger->statement;

View File

@ -29,7 +29,7 @@ class TriggerTest extends TestCase
$this->assertSame('trigger_name', $actual->name);
$this->assertSame(Timing::Before, $actual->timing);
$this->assertSame(Event::Update, $actual->event);
$this->assertSame('test_table', $actual->table);
$this->assertSame('test_table', $actual->table->getName());
$this->assertSame('BEGIN END', $actual->statement);
$this->assertSame('definer@localhost', $actual->definer);
}