/** * {@inheritdoc} */ public function setUp() { parent::setUp(); $this->connection->execute("CREATE TABLE IF NOT EXISTS `stats_snapshots` (\n `id` INT UNSIGNED AUTO_INCREMENT NOT NULL,\n `account_id` INT UNSIGNED DEFAULT NULL,\n `day` DATE DEFAULT NULL,\n `is_used_on_day` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',\n `stats` JSON DEFAULT NULL,\n `plan_name` VARCHAR(191) AS (`stats`->>'\$.plan_name'),\n `number_of_users` INT AS (`stats`->>'\$.users'),\n PRIMARY KEY (`id`),\n INDEX `account_id` (`account_id`)\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;"); // For the test purposes, each odd day will be set as used, and each even will be set as not used. $this->connection->execute('CREATE TRIGGER `insert_stats_snapshots` BEFORE INSERT ON `stats_snapshots` FOR EACH ROW SET NEW.`is_used_on_day` = MOD(DAY(NEW.`day`), 2);'); $this->connection->execute('CREATE TRIGGER `update_stats_snapshots` BEFORE UPDATE ON `stats_snapshots` FOR EACH ROW SET NEW.`is_used_on_day` = MOD(DAY(NEW.`day`), 2);'); $this->pool->registerType(StatsSnapshot::class); }
/** * Set up test environment. */ public function setUp() { parent::setUp(); $container = new Container(['dependency' => 'it works!']); $this->pool->setContainer($container); $this->assertTrue($this->pool->hasContainer()); $this->assertInstanceOf(Container::class, $this->pool->getContainer()); $this->pool->registerType(Writer::class); }
/** * Set up test environment. */ public function setUp() { parent::setUp(); if ($this->connection->tableExists('writers')) { $this->connection->dropTable('writers'); } $create_table = $this->connection->execute('CREATE TABLE `writers` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(191) COLLATE utf8mb4_unicode_ci, `birthday` date NOT NULL, `created_at` datetime DEFAULT CURRENT_TIMESTAMP, `updated_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;'); $this->assertTrue($create_table); $this->connection->execute('INSERT INTO `writers` (`name`, `birthday`) VALUES (?, ?), (?, ?), (?, ?)', 'Leo Tolstoy', new DateValue('1828-09-09'), 'Alexander Pushkin', new DateValue('1799-06-06'), 'Fyodor Dostoyevsky', new DateValue('1821-11-11')); $this->pool->registerType(Writer::class); $this->assertTrue($this->pool->isTypeRegistered(Writer::class)); }
/** * Set up test environment. */ public function setUp() { parent::setUp(); $this->pool->registerType(User::class); $this->assertTrue($this->pool->isTypeRegistered(User::class)); }