getSubscribedEvents(); $this->assertTrue(\in_array(Events::postConnect, $events)); } public function testPostConnectWithSqlite() { $sut = new SqliteSessionInitSubscriber(); $platformMock = $this->getMockBuilder(SqlitePlatform::class) ->onlyMethods(['getName']) ->disableOriginalConstructor() ->getMock(); $platformMock->expects($this->once())->method('getName')->willReturn('sqlite'); $connectionMock = $this->createMock(Connection::class); $connectionMock->expects($this->once())->method('getDatabasePlatform')->willReturn($platformMock); $connectionMock->expects($this->once())->method('exec')->with('PRAGMA foreign_keys = ON;'); $args = new ConnectionEventArgs($connectionMock); $sut->postConnect($args); } public function testPostConnectWithMysql() { $sut = new SqliteSessionInitSubscriber(); $platformMock = $this->getMockBuilder(MySqlPlatform::class) ->onlyMethods(['getName']) ->disableOriginalConstructor() ->getMock(); $platformMock->expects($this->once())->method('getName')->willReturn('mysql'); $connectionMock = $this->createMock(Connection::class); $connectionMock->expects($this->once())->method('getDatabasePlatform')->willReturn($platformMock); $connectionMock->expects($this->never())->method('exec')->with('PRAGMA foreign_keys = ON;'); $args = new ConnectionEventArgs($connectionMock); $sut->postConnect($args); } }