[1.7.x] Fixed #23352 -- Added tests for MigrationGraph.{forwards,backwards}_plan

Backports of c077487 from master