South African mining companies won court backing on a crucial black-ownership principle that’s likely to have implications for ongoing negotiations with President Cyril Ramaphosa’s government.