Expects
An expectation is an assertion that a test has passed.
#Usage
Expectation starting with Expect::that.
Copied!
1Expect::that(<something)
There, you expect that something will be something.
#Generic
| Expect |
|---|
| contains |
| notContains |
| startsWith |
| endsWith |
| isTheSameAs |
| samePriceAs |
| equals |
| isNull |
| isNotNull |
| isNotEmpty |
| isBetween |
| isGreaterThan |
| isLessThan |
| isGreaterThanOrEqualTo |
| isLessThanOrEqualTo |
#Elements
| Expect |
|---|
| elementIsVisible |
| elementIsNotVisible |
#Shop
| Expect |
|---|
| shopIsInMaintenance |
| shopIsNotInMaintenance |
| shopIsVisible |
| shopIsNotVisible |
#Customer
| Expect |
|---|
| customerIsLogged |
| customerIsNotLogged |
#Example
Copied!
1use PrestaFlow\Library\Expects\Expect; 2 3class ModuleCustom extends Scenario 4{ 5 public function steps($testSuite) 6 { 7 $this->importPage('Modules\Custom', domain: 'Shop\Tests'); 8 $this->importPage('FrontOffice\Category'); 9 10 extract($this->pages);11 12 $testSuite13 ->it('should go to page', function () use ($modulesCustomPage) {14 $modulesCustomPage->goToPage($modulesCustomPage);15 16 Expect::that($modulesCustomPage->getPageTitle())->contains($modulesCustomPage->pageTitle());17 })18 19 ;20 21 return $testSuite;22 }23}
#Using a custom expected message
Copied!
1Expect::that($productPrice)->samePriceAs($productPriceExpected, "{value} need to be like {expected}");