/** * Returns all triggers on a table. * * @param string $table_name The name of the table. * * @return \array[] */ private function getTableTriggers($table_name) { AuditDataLayer::disconnect(); AuditDataLayer::connect('localhost', 'test', 'test', self::$dataSchema); $triggers = AuditDataLayer::getTableTriggers(self::$dataSchema, $table_name); return $triggers; }
/** * Connects to a MySQL instance. * * @param array $settings The settings from the configuration file. */ protected function connect($settings) { $host = $this->getSetting($settings, true, 'database', 'host'); $user = $this->getSetting($settings, true, 'database', 'user'); $password = $this->getSetting($settings, true, 'database', 'password'); $database = $this->getSetting($settings, true, 'database', 'data_schema'); AuditDataLayer::setIo($this->io); AuditDataLayer::connect($host, $user, $password, $database); }
/** * Test audit table is created correctly. */ public function test01() { $application = new Application(); $application->add(new AuditCommand()); /** @var AuditCommand $command */ $command = $application->find('audit'); $command->setRewriteConfigFile(false); $commandTester = new CommandTester($command); $commandTester->execute(['command' => $command->getName(), 'config file' => __DIR__ . '/config/audit.json']); $this->assertSame(0, $commandTester->getStatusCode()); // Reconnect to DB. AuditDataLayer::connect('localhost', 'test', 'test', self::$dataSchema); $table1_data = AuditDataLayer::getTableOptions('test_data', 'TABLE1'); $table1_audit = AuditDataLayer::getTableOptions('test_audit', 'TABLE1'); $this->assertEquals($table1_data, $table1_audit, 'TABLE1'); $table1_data = AuditDataLayer::getTableOptions('test_data', 'TABLE2'); $table1_audit = AuditDataLayer::getTableOptions('test_audit', 'TABLE2'); $this->assertEquals($table1_data, $table1_audit, 'TABLE2'); $table1_data = AuditDataLayer::getTableOptions('test_data', 'TABLE3'); $table1_audit = AuditDataLayer::getTableOptions('test_audit', 'TABLE3'); $this->assertEquals($table1_data, $table1_audit, 'TABLE3'); }
private function runAudit() { $application = new Application(); $application->add(new AuditCommand()); /** @var AuditCommand $command */ $command = $application->find('audit'); $command->setRewriteConfigFile(false); $commandTester = new CommandTester($command); $commandTester->execute(['command' => $command->getName(), 'config file' => __DIR__ . '/config/audit.json']); // Reconnect to MySQL. StaticDataLayer::disconnect(); StaticDataLayer::connect('localhost', 'test', 'test', self::$dataSchema); AuditDataLayer::connect('localhost', 'test', 'test', self::$dataSchema); }