/** * @test */ public function it_uses_custom_snapshot_table_map() { $schema = new Schema(); SnapshotStoreSchema::create($schema, 'bar'); foreach ($schema->toSql($this->connection->getDatabasePlatform()) as $sql) { $this->connection->executeQuery($sql); } $adapter = new DoctrineSnapshotAdapter($this->connection, ['foo' => 'bar']); $aggregateType = AggregateType::fromString('foo'); $aggregateRoot = new \stdClass(); $aggregateRoot->foo = 'bar'; $time = microtime(true); if (false === strpos($time, '.')) { $time .= '.0000'; } $now = \DateTimeImmutable::createFromFormat('U.u', $time); $snapshot = new Snapshot($aggregateType, 'id', $aggregateRoot, 1, $now); $adapter->add($snapshot); $queryBuilder = $this->connection->createQueryBuilder(); $queryBuilder->select('*')->from('bar', 'bar')->setMaxResults(1); $stmt = $queryBuilder->execute(); $this->assertNotNull($stmt->fetch(\PDO::FETCH_ASSOC)); }
/** * @test */ public function it_drops_snapshot_table() { $schema = $this->prophesize(Schema::class); $schema->dropTable('table_name'); SnapshotStoreSchema::drop($schema->reveal(), 'table_name'); }