qa-tools / qa-tools

Library that provides easy-to-use way of interaction with web-page elements in functional tests using PageObject pattern.
https://qa-tools.github.io
BSD 3-Clause "New" or "Revised" License
51 stars 14 forks source link

Convert Mink "has*" methods into phpUnit assertions #8

Open aik099 opened 10 years ago

aik099 commented 10 years ago

Right now Mink has nice has* methods (e.g. hasContent, hasTag, etc.), that returns true or false. However error messages when something fails, produced by $this->assertTrue method are totally useless:

Failed asserting that false is true.

Create a set of constrains, that would make life easier, when dealing with Mink, e.g. $this->assertPageHasContent($page, 'content here') would produce following error message:

Failed asserting, that page <page_class_name> (url: <url_to_a_page>) has "<content here>" on it.

Probably we can just copy paste PHPUnit Selenium ones from here https://github.com/sebastianbergmann/phpunit-selenium/blob/master/PHPUnit/Extensions/SeleniumTestCase.php:

 * @method unknown  assertAlert
 * @method unknown  assertAlertNotPresent
 * @method unknown  assertAlertPresent
 * @method unknown  assertAllButtons
 * @method unknown  assertAllFields
 * @method unknown  assertAllLinks
 * @method unknown  assertAllWindowIds
 * @method unknown  assertAllWindowNames
 * @method unknown  assertAllWindowTitles
 * @method unknown  assertAttribute
 * @method unknown  assertAttributeFromAllWindows
 * @method unknown  assertBodyText
 * @method unknown  assertChecked
 * @method unknown  assertConfirmation
 * @method unknown  assertConfirmationNotPresent
 * @method unknown  assertConfirmationPresent
 * @method unknown  assertCookie
 * @method unknown  assertCookieByName
 * @method unknown  assertCookieNotPresent
 * @method unknown  assertCookiePresent
 * @method unknown  assertCssCount
 * @method unknown  assertCursorPosition
 * @method unknown  assertEditable
 * @method unknown  assertElementHeight
 * @method unknown  assertElementIndex
 * @method unknown  assertElementNotPresent
 * @method unknown  assertElementPositionLeft
 * @method unknown  assertElementPositionTop
 * @method unknown  assertElementPresent
 * @method unknown  assertElementWidth
 * @method unknown  assertEval
 * @method unknown  assertExpression
 * @method unknown  assertHtmlSource
 * @method unknown  assertLocation
 * @method unknown  assertLogMessages
 * @method unknown  assertMouseSpeed
 * @method unknown  assertNotAlert
 * @method unknown  assertNotAllButtons
 * @method unknown  assertNotAllFields
 * @method unknown  assertNotAllLinks
 * @method unknown  assertNotAllWindowIds
 * @method unknown  assertNotAllWindowNames
 * @method unknown  assertNotAllWindowTitles
 * @method unknown  assertNotAttribute
 * @method unknown  assertNotAttributeFromAllWindows
 * @method unknown  assertNotBodyText
 * @method unknown  assertNotChecked
 * @method unknown  assertNotConfirmation
 * @method unknown  assertNotCookie
 * @method unknown  assertNotCookieByName
 * @method unknown  assertNotCssCount
 * @method unknown  assertNotCursorPosition
 * @method unknown  assertNotEditable
 * @method unknown  assertNotElementHeight
 * @method unknown  assertNotElementIndex
 * @method unknown  assertNotElementPositionLeft
 * @method unknown  assertNotElementPositionTop
 * @method unknown  assertNotElementWidth
 * @method unknown  assertNotEval
 * @method unknown  assertNotExpression
 * @method unknown  assertNotHtmlSource
 * @method unknown  assertNotLocation
 * @method unknown  assertNotLogMessages
 * @method unknown  assertNotMouseSpeed
 * @method unknown  assertNotOrdered
 * @method unknown  assertNotPrompt
 * @method unknown  assertNotSelectOptions
 * @method unknown  assertNotSelectedId
 * @method unknown  assertNotSelectedIds
 * @method unknown  assertNotSelectedIndex
 * @method unknown  assertNotSelectedIndexes
 * @method unknown  assertNotSelectedLabel
 * @method unknown  assertNotSelectedLabels
 * @method unknown  assertNotSelectedValue
 * @method unknown  assertNotSelectedValues
 * @method unknown  assertNotSomethingSelected
 * @method unknown  assertNotSpeed
 * @method unknown  assertNotSpeedAndWait
 * @method unknown  assertNotTable
 * @method unknown  assertNotText
 * @method unknown  assertNotTitle
 * @method unknown  assertNotValue
 * @method unknown  assertNotVisible
 * @method unknown  assertNotWhetherThisFrameMatchFrameExpression
 * @method unknown  assertNotWhetherThisWindowMatchWindowExpression
 * @method unknown  assertNotXpathCount
 * @method unknown  assertOrdered
 * @method unknown  assertPrompt
 * @method unknown  assertPromptNotPresent
 * @method unknown  assertPromptPresent
 * @method unknown  assertSelectOptions
 * @method unknown  assertSelectedId
 * @method unknown  assertSelectedIds
 * @method unknown  assertSelectedIndex
 * @method unknown  assertSelectedIndexes
 * @method unknown  assertSelectedLabel
 * @method unknown  assertSelectedLabels
 * @method unknown  assertSelectedValue
 * @method unknown  assertSelectedValues
 * @method unknown  assertSomethingSelected
 * @method unknown  assertSpeed
 * @method unknown  assertSpeedAndWait
 * @method unknown  assertTable
 * @method unknown  assertText
 * @method unknown  assertTextNotPresent
 * @method unknown  assertTextPresent
 * @method unknown  assertTitle
 * @method unknown  assertValue
 * @method unknown  assertVisible
 * @method unknown  assertWhetherThisFrameMatchFrameExpression
 * @method unknown  assertWhetherThisWindowMatchWindowExpression
 * @method unknown  assertXpathCount
stof commented 10 years ago

the first step could be to expose the WebAssert assertion

aik099 commented 10 years ago

I didn't knew that WebAssert class existed at time of creating this issue.