The case was brought by two Polish men who married in Germany and wanted to have their union recognised in Poland.