This test demonstrates a content rule that triggers for multiple objects
during the same request.

Setup
-----

  >>> from plone.app.testing import SITE_OWNER_NAME, SITE_OWNER_PASSWORD
  >>> from plone.testing.z2 import Browser
  >>> from plone.app.testing import setRoles
  >>> from plone.app.testing import TEST_USER_ID

  >>> portal = layer['portal']
  >>> setRoles(portal, TEST_USER_ID, ['Manager'])
  >>> obj = portal.invokeFactory('Folder', 'news')
  >>> import transaction
  >>> transaction.commit()

  >>> browser = Browser(layer['app'])
  >>> browser.addHeader('Authorization',
  ...                   'Basic %s:%s' % (SITE_OWNER_NAME, SITE_OWNER_PASSWORD))

Let's visit the control panel and add a content rule.  We'll add a
rule with a triggering event of `Workflow state changed`:

  >>> browser.open(portal.absolute_url())
  >>> browser.getLink('Site Setup').click()
  >>> browser.getLink('Content Rules').click()
  >>> browser.getLink('Add content rule').click()
  >>> browser.getControl('Title').value = 'Move Published News'
  >>> ctrl = browser.getControl('Triggering event')
  >>> ctrl.value = ['Workflow state changed']
  >>> browser.getControl('Save').click()

We're back at the control panel.  Now we'll edit the content rule.
We'll add a portal type condition for *news items* and a workflow state
condition for *published*:

  >>> browser.url
  'http://nohost/plone/++rule++rule-1/@@manage-elements'
  >>> browser.getControl('Add condition').value = [
  ...     'plone.conditions.PortalType']
  >>> browser.getControl(name='form.button.AddCondition').click()
  >>> browser.getControl('Content type').value = ['News Item']
  >>> browser.getControl('Save').click()

  >>> browser.getControl('Add condition').value = [
  ...     'plone.conditions.WorkflowState']
  >>> browser.getControl(name='form.button.AddCondition').click()
  >>> browser.getControl('Workflow state').value = ['published']
  >>> browser.getControl('Save').click()

Now comes the action, we want all news items to be moved into the
`/news` folder:

  >>> browser.getControl('Add action').value = ['plone.actions.Move']
  >>> browser.getControl(name='form.button.AddAction').click()
  >>> ctrl = browser.getControl(name='form.widgets.target_folder')
  >>> from plone.uuid.interfaces import IUUID
  >>> ctrl.value = IUUID(portal.news)
  >>> browser.getControl('Save').click()

We're done with setting up the content rule.  We need to now apply the
rule to the root of the site before we try to add some news items:

  >>> browser.getLink('Home').click()
  >>> browser.getLink('Rules').click()
  >>> browser.getControl(name='rule_id').displayOptions
  ['Move Published News']
  >>> browser.getControl('Add').click()

Let's go back and create two news items now:

  >>> browser.getLink('Home').click()
  >>> browser.getLink('Add new').click()
  >>> browser.getControl('News Item').click()
  >>> browser.getControl('Add').click()
  >>> browser.getControl('Title').value = 'My news item'
  >>> browser.getControl('Save').click()
  >>> 'Item created' in browser.contents
  True

  >>> browser.getLink('Home').click()
  >>> browser.getLink('Add new').click()
  >>> browser.getControl('News Item').click()
  >>> browser.getControl('Add').click()
  >>> browser.getControl('Title').value = 'Second news item'
  >>> browser.getControl('Save').click()
  >>> 'Item created' in browser.contents
  True

Now let's publish both simultaneously.

  >>> browser.getLink('Home').click()
  >>> browser.open('http://nohost/plone/content_status_history?paths:list=my-news-item&paths:list=second-news-item')
  >>> browser.getControl('Publish').click()
  >>> try: # Work around https://bugs.launchpad.net/zope3/+bug/98437
  ...     browser.getControl('Save').click()
  ... except:
  ...     pass

Both news items should have moved into the `news/` folder now:

  >>> browser.open(portal.absolute_url() + '/news/folder_listing')
  >>> 'My news item' in browser.contents
  True
  >>> 'Second news item' in browser.contents
  True
