objectManager = Bootstrap::getObjectManager(); $this->layout = $this->objectManager->get(LayoutInterface::class); $this->block = $this->layout->createBlock(Newsletter::class); $this->customerSession = $this->objectManager->get(Session::class); } /** * @return void */ public function testSubscriptionCheckbox(): void { $this->customerSession->loginById(1); $html = $this->block->toHtml(); $this->assertEquals( 1, Xpath::getElementsCountForXpath(self::LABEL_XPATH, $html), 'Subscription label is not present on the page' ); $this->assertEquals( 1, Xpath::getElementsCountForXpath(self::CHECKBOX_XPATH, $html), 'Subscription checkbox is not present on the page' ); $this->assertEquals( 1, Xpath::getElementsCountForXpath(self::CHECKBOX_TITLE_XPATH, $html), 'Subscription checkbox label is not present on the page' ); $this->assertEquals( 1, Xpath::getElementsCountForXpath(self::SAVE_BUTTON_XPATH, $html), 'Subscription save button is not present on the page' ); } }