This tests the correct creation of references used for ensuring link
integrity. Any archetype-based content object which refers to other (local)
objects by `
` or `` tags should create references between those
objects on save. First we check neither the document nor the image have any
references yet:
>>> doc = portal.doc1
>>> self.assertEqual(doc.getReferences(), [])
>>> self.assertEqual(doc.getBackReferences(), [])
>>> img = portal.image1
>>> self.assertEqual(img.getReferences(), [])
>>> self.assertEqual(img.getBackReferences(), [])
Then we edit the document and insert a link to the image, which should
trigger the creation of the references. We need to use ``processForm()`` here,
because using the mutator won't call ``notify`` and therefore not trigger
the `IObjectModifiedEvent` event either:
>>> self.setRoles(('Manager',))
>>> tag = img.tag()
>>> str(tag)
'
'
>>> self.setText(doc, tag)
>>> doc.getReferences()
[]
>>> doc.getBackReferences()
[]
>>> img.getReferences()
[]
>>> img.getBackReferences()
[]
Next we change the document again and insert a link to another page:
>>> self.setText(doc, 'news')
>>> doc.getReferences()
[]
>>> portal.news.getBackReferences()
[]
Linking image scales should also work:
>>> self.setText(doc, 'an image')
>>> doc.getReferences()
[]
>>> img.getBackReferences()
[]
Linking via the "resolveuid/UID" method should also work:
>>> self.setText(doc, 'an image' % (
... img.UID(),))
>>> doc.getReferences()
[]
>>> img.getBackReferences()
[]