==============================================================================
A basic search and replace test
==============================================================================

Create the browser object we'll be using.

    >>> from plone.testing import z2
    >>> from plone.app.testing import TEST_USER_NAME
    >>> from plone.app.testing import TEST_USER_PASSWORD
    >>> browser = z2.Browser(layer['app'])
    >>> portal = layer['portal']
    >>> portal_url = portal.absolute_url()

Open the portal as anonymous and check is action available

    >>> browser.open(portal_url)
    >>> 'Search/Replace' in browser.contents
    False


Open the portal and login as Member
    >>> portal.portal_membership.addMember('member','secret',('Member',),())
    >>> import transaction
    >>> transaction.commit()
    >>> browser.open(portal_url + '/page')
    >>> browser.getLink('Log in').click()
    >>> browser.getControl('Login Name').value = 'member'
    >>> browser.getControl('Password').value = 'secret'
    >>> browser.getControl('Log in').click()
    >>> 'Login failed.' in browser.contents
    False

Check if action is available for Member
    >>> browser.open(portal_url)
    >>> 'Search/Replace' in browser.contents
    False


Open the portal and login as Contributor
    >>> browser.getLink('Log out').click()
    >>> portal.portal_membership.addMember('contrib','secret',('Contributor',),())
    >>> transaction.commit()
    >>> browser.open(portal_url + '/page')
    >>> browser.getLink('Log in').click()
    >>> browser.getControl('Login Name').value = 'contrib'
    >>> browser.getControl('Password').value = 'secret'
    >>> browser.getControl('Log in').click()
    >>> 'Login failed.' in browser.contents
    False

Check if action is available for Contributor that doesn't have permissions on front-page
    >>> browser.open(portal_url)
    >>> 'Search/Replace' in browser.contents
    False

Check if action is available for Contributor that creates an object
    >>> browser.getLink('Page').click()
    >>> browser.getControl('Title').value = 'Test Page'
    >>> browser.getControl('Save').click()
    >>> browser.getLink('Search/Replace').click()
    >>> 'Search/Replace' in browser.contents
    True
