diff --git a/index (3).php b/index (3).php new file mode 100644 index 0000000..e8d0dff --- /dev/null +++ b/index (3).php @@ -0,0 +1,43 @@ +pdo = $pdo; + } + + public function up() { + $sql = "CREATE TABLE users ( + id INT AUTO_INCREMENT PRIMARY KEY, + name VARCHAR(50) NOT NULL, + email VARCHAR(100) NOT NULL + )"; + $this->pdo->exec($sql); + } + + public function down() { + $sql = "DROP TABLE users"; + $this->pdo->exec($sql); + } +} + +class MigrationTest extends TestCase { + public function testRollbackMigration() { + $pdoMock = $this->getMockBuilder(PDO::class) + ->disableOriginalConstructor() + ->getMock(); + + $migrationMock = $this->getMockBuilder(Migration::class) + ->setConstructorArgs([$pdoMock]) + ->onlyMethods(['up', 'down']) + ->getMock(); + + $migrationMock->expects($this->once()) + ->method('down'); + + $migrationMock->down(); + } +} \ No newline at end of file