void MyMoneySplitTest::testReplaceId() { MyMoneySplit s; bool changed; s.setPayeeId("P000001"); s.setAccountId("A000076"); changed = s.replaceId("X0001", "Y00001"); QVERIFY(changed == false); QVERIFY(s.payeeId() == "P000001"); QVERIFY(s.accountId() == "A000076"); changed = s.replaceId("P000002", "P000001"); QVERIFY(changed == true); QVERIFY(s.payeeId() == "P000002"); QVERIFY(s.accountId() == "A000076"); changed = s.replaceId("A000079", "A000076"); QVERIFY(changed == true); QVERIFY(s.payeeId() == "P000002"); QVERIFY(s.accountId() == "A000079"); QString ref_ok = QString( "<!DOCTYPE TEST>\n" "<SPLIT-CONTAINER>\n" " <SPLIT payee=\"P000001\" reconciledate=\"\" shares=\"-125000/100\" action=\"Transfer\" bankid=\"A000076-2010-03-05-b6850c0-1\" number=\"\" reconcileflag=\"1\" memo=\"UMBUCHUNG\" value=\"-125000/100\" id=\"S0001\" account=\"A000076\" >\n" " <KEYVALUEPAIRS>\n" " <PAIR key=\"kmm-match-split\" value=\"S0002\" />\n" " <PAIR key=\"kmm-matched-tx\" value=\"&lt;!DOCTYPE MATCH>\n" " &lt;CONTAINER>\n" " &lt;TRANSACTION postdate="2010-03-05" memo="UMBUCHUNG" id="" commodity="EUR" entrydate="2010-03-08" >\n" " &lt;SPLITS>\n" " &lt;SPLIT payee="P000010" reconciledate="" shares="125000/100" action="Transfer" bankid="" number="" reconcileflag="0" memo="UMBUCHUNG" value="125000/100" id="S0001" account="A000087" />\n" " &lt;SPLIT payee="P000011" reconciledate="" shares="-125000/100" action="" bankid="A000076-2010-03-05-b6850c0-1" number="" reconcileflag="0" memo="UMBUCHUNG" value="-125000/100" id="S0002" account="A000076" />\n" " &lt;/SPLITS>\n" " &lt;KEYVALUEPAIRS>\n" " &lt;PAIR key="Imported" value="true" />\n" " &lt;/KEYVALUEPAIRS>\n" " &lt;/TRANSACTION>\n" " &lt;/CONTAINER>\n" "\" />\n" " <PAIR key=\"kmm-orig-memo\" value=\"\" />\n" " </KEYVALUEPAIRS>\n" " </SPLIT>\n" "</SPLIT-CONTAINER>\n" ); QDomDocument doc; QDomElement node; doc.setContent(ref_ok); node = doc.documentElement().firstChild().toElement(); try { s = MyMoneySplit(node); QVERIFY(s.payeeId() == "P000001"); QVERIFY(s.replaceId("P2", "P1") == false); QVERIFY(s.matchedTransaction().splits()[0].payeeId() == "P000010"); QVERIFY(s.matchedTransaction().splits()[1].payeeId() == "P000011"); QVERIFY(s.replaceId("P0010", "P000010") == true); QVERIFY(s.matchedTransaction().splits()[0].payeeId() == "P0010"); QVERIFY(s.matchedTransaction().splits()[1].payeeId() == "P000011"); QVERIFY(s.replaceId("P0011", "P000011") == true); QVERIFY(s.matchedTransaction().splits()[0].payeeId() == "P0010"); QVERIFY(s.matchedTransaction().splits()[1].payeeId() == "P0011"); } catch (const MyMoneyException &) { QFAIL("Unexpected exception"); } }