This tests the behaviour when removing a referenced file that has
spaces in its id.  First we need to rename the existing file:

  >>> self.setRoles(('Manager',))
  >>> file_with_spaces = portal.file1
  >>> file_with_spaces.setId('some spaces.doc')
  >>> file_with_spaces.getId()
  'some spaces.doc'

Check that the file is there with the id that we expect:

  >>> portal['some spaces.doc']
  <ATFile at /plone/some spaces.doc>

Now we create the necessary links:

  >>> tmpl = '<a href="%s">%s</a>'
  >>> p = self.portal
  >>> self.setText(p.doc1, tmpl % (file_with_spaces.absolute_url(),
  ...   file_with_spaces.title_or_id()))

The document should now have a reference to the file:

  >>> p.doc1.getRefs()
  [<ATFile at /plone/some spaces.doc>]

Then we use a browser to try to delete the referenced file.  Before we
can do this we need to prevent the test framework from choking on the
exception we intentionally throw (see docs/testRemovalTriggersConfirmation.txt
for more info).  Also, we disable the event count helper (as set in
folder_contents), so that all tests written so far won't need modification:

  >>> self.setStatusCode('LinkIntegrityNotificationException', 200)
  >>> self.disableEventCountHelper()
  >>> browser = self.getBrowser(loggedIn=True)
  >>> browser.open('http://nohost/plone/folder_contents')
  >>> browser.getControl('Test File 1').selected = True
  >>> browser.getControl('Delete').click()
  >>> browser.contents
  '...<a href="http://nohost/plone/some%20spaces.doc"...Test File 1...
   ...This...File...is referenced by the following items:...
   ...<li>...href="http://nohost/plone/doc1"...Test Page 1...</li>...
   ...Would you like to delete it anyway?...'
  >>> browser.getControl(name='delete').click()

After we acknowledge the breaches in link integrity the file should have
been deleted::

  >>> portal['some spaces.doc']
  Traceback (most recent call last):
  ...
  KeyError: 'some spaces.doc'
