Skip to content

Commit e6e2dc3

Browse files
Merge pull request #8218 from magento-gl/integration-tests-mainline
Integration tests mainline
2 parents 9187ec1 + 49e79e6 commit e6e2dc3

File tree

8 files changed

+577
-1
lines changed

8 files changed

+577
-1
lines changed

app/code/Magento/Search/Test/Mftf/Test/ElasticsearchProductCanBeFoundByValueOfSearchableAttributeTest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
<description value="Product can be found by value of 'Searchable' attribute"/>
1616
<severity value="MAJOR"/>
1717
<testCaseId value="AC-4086"/>
18+
<skip>
19+
<issueId value="ACQE-4825"/>
20+
</skip>
1821
</annotations>
1922

2023
<before>
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CatalogUrlRewrite\Model;
9+
10+
use Magento\Catalog\Api\ProductRepositoryInterface;
11+
use Magento\CatalogUrlRewrite\Model\Map\DataProductUrlRewriteDatabaseMap;
12+
use Magento\Store\Model\ScopeInterface;
13+
use Magento\TestFramework\Fixture\DataFixture;
14+
use Magento\Catalog\Model\Product\Visibility;
15+
use Magento\Catalog\Test\Fixture\Product as ProductFixture;
16+
17+
/**
18+
* Class for product url rewrites tests
19+
*
20+
*/
21+
class ProductUrlRewriteVisibilityTest extends AbstractUrlRewriteTest
22+
{
23+
private const URL_KEY_EMPTY_MESSAGE = 'Failed asserting URL key is empty for the given product';
24+
25+
/** @var string */
26+
private $suffix;
27+
28+
/** @var ProductRepositoryInterface */
29+
private $productRepository;
30+
31+
/**
32+
* @inheritdoc
33+
*/
34+
protected function setUp(): void
35+
{
36+
parent::setUp();
37+
38+
$this->productRepository = $this->objectManager->create(ProductRepositoryInterface::class);
39+
$this->suffix = $this->config->getValue(
40+
ProductUrlPathGenerator::XML_PATH_PRODUCT_URL_SUFFIX,
41+
ScopeInterface::SCOPE_STORE
42+
);
43+
}
44+
45+
/**
46+
* @magentoConfigFixture default/catalog/seo/generate_category_product_rewrites 1
47+
* @dataProvider invisibleProductDataProvider
48+
* @param array $expectedData
49+
* @return void
50+
*/
51+
#[
52+
DataFixture(ProductFixture::class, ['sku' => 'simple', 'name' => 'Simple Url Test Product',
53+
'visibility' => Visibility::VISIBILITY_NOT_VISIBLE]),
54+
]
55+
public function testUrlRewriteOnInvisibleProductEdit(array $expectedData): void
56+
{
57+
$product = $this->productRepository->get('simple', true, 0, true);
58+
$this->assertUrlKeyEmpty($product, self::URL_KEY_EMPTY_MESSAGE);
59+
60+
//Update visibility and check the database entry
61+
$product->setVisibility(Visibility::VISIBILITY_BOTH);
62+
$product = $this->productRepository->save($product);
63+
64+
$productUrlRewriteCollection = $this->getEntityRewriteCollection($product->getId());
65+
$this->assertRewrites(
66+
$productUrlRewriteCollection,
67+
$this->prepareData($expectedData, (int)$product->getId())
68+
);
69+
70+
//Update visibility and check if the entry is removed from the database
71+
$product = $this->productRepository->get('simple', true, 0, true);
72+
$product->setVisibility(Visibility::VISIBILITY_NOT_VISIBLE);
73+
$product = $this->productRepository->save($product);
74+
75+
$this->assertUrlKeyEmpty($product, self::URL_KEY_EMPTY_MESSAGE);
76+
}
77+
78+
/**
79+
* @return array
80+
*/
81+
public function invisibleProductDataProvider(): array
82+
{
83+
return [
84+
[
85+
'expected_data' => [
86+
[
87+
'request_path' => 'simple-url-test-product%suffix%',
88+
'target_path' => 'catalog/product/view/id/%id%',
89+
],
90+
],
91+
],
92+
];
93+
}
94+
95+
/**
96+
* Assert URL key is empty in database for the given product
97+
*
98+
* @param $product
99+
* @param string $message
100+
*
101+
* @return void
102+
*/
103+
public function assertUrlKeyEmpty($product, $message = ''): void
104+
{
105+
$productUrlRewriteItems = $this->getEntityRewriteCollection($product->getId())->getItems();
106+
$this->assertEmpty($productUrlRewriteItems, $message);
107+
}
108+
109+
/**
110+
* @inheritdoc
111+
*/
112+
protected function getUrlSuffix(): string
113+
{
114+
return $this->suffix;
115+
}
116+
117+
/**
118+
* @inheritdoc
119+
*/
120+
protected function getEntityType(): string
121+
{
122+
return DataProductUrlRewriteDatabaseMap::ENTITY_TYPE;
123+
}
124+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\ConfigurableProduct\Controller\Adminhtml\Product\Attribute;
9+
10+
use Magento\Catalog\Api\ProductAttributeRepositoryInterface;
11+
use Magento\Catalog\Api\ProductRepositoryInterface;
12+
use Magento\ConfigurableProduct\Test\Fixture\Attribute as AttributeFixture;
13+
use Magento\Framework\Exception\LocalizedException;
14+
use Magento\TestFramework\Fixture\DataFixture;
15+
use Magento\TestFramework\TestCase\AbstractBackendController;
16+
use Magento\Eav\Model\Config;
17+
use Magento\Catalog\Api\Data\ProductAttributeInterface;
18+
19+
/**
20+
* Checks creating attribute options process.
21+
*
22+
* @see \Magento\ConfigurableProduct\Controller\Adminhtml\Product\Attribute\UpdateProductAttributeTest
23+
* @magentoAppArea adminhtml
24+
* @magentoDbIsolation enabled
25+
*/
26+
class UpdateProductAttributeTest extends AbstractBackendController
27+
{
28+
/**
29+
* @var ProductAttributeRepositoryInterface
30+
*/
31+
private $productAttributeRepository;
32+
33+
/**
34+
* @var Config
35+
*/
36+
private $eavConfig;
37+
38+
/**
39+
* @inheritdoc
40+
*/
41+
protected function setUp(): void
42+
{
43+
parent::setUp();
44+
45+
$productRepository = $this->_objectManager->get(ProductRepositoryInterface::class);
46+
$productRepository->cleanCache();
47+
$this->productAttributeRepository = $this->_objectManager->create(ProductAttributeRepositoryInterface::class);
48+
$this->eavConfig = $this->_objectManager->create(Config::class);
49+
}
50+
51+
/**
52+
* Test updating a product attribute and checking the frontend_class for the sku attribute.
53+
*
54+
* @return void
55+
* @throws LocalizedException
56+
*/
57+
#[
58+
DataFixture(AttributeFixture::class, as: 'attr'),
59+
]
60+
public function testAttributeWithBackendTypeHasSameValueInFrontendClass()
61+
{
62+
// Load the 'sku' attribute.
63+
/** @var ProductAttributeInterface $attribute */
64+
$attribute = $this->productAttributeRepository->get('sku');
65+
$expectedFrontEndClass = $attribute->getFrontendClass();
66+
67+
// Save the attribute.
68+
$this->productAttributeRepository->save($attribute);
69+
70+
// Check that the value of the frontend_class changed or not.
71+
try {
72+
$skuAttribute = $this->eavConfig->getAttribute('catalog_product', 'sku');
73+
$this->assertEquals($expectedFrontEndClass, $skuAttribute->getFrontendClass());
74+
} catch (LocalizedException $e) {
75+
$this->fail($e->getMessage());
76+
}
77+
}
78+
}

dev/tests/integration/testsuite/Magento/Customer/Model/AccountManagement/ForgotPasswordTest.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@
99

1010
use Magento\Customer\Api\AccountManagementInterface;
1111
use Magento\Customer\Model\AccountManagement;
12+
use Magento\Customer\Test\Fixture\Customer;
13+
use Magento\Framework\Exception\LocalizedException;
1214
use Magento\Framework\ObjectManagerInterface;
15+
use Magento\Store\Model\StoreManagerInterface;
16+
use Magento\TestFramework\Fixture\DataFixture;
17+
use Magento\TestFramework\Fixture\DataFixtureStorage;
18+
use Magento\TestFramework\Fixture\DataFixtureStorageManager;
1319
use Magento\TestFramework\Helper\Bootstrap;
1420
use Magento\TestFramework\Helper\Xpath;
1521
use Magento\TestFramework\Mail\Template\TransportBuilderMock;
@@ -35,6 +41,12 @@ class ForgotPasswordTest extends TestCase
3541
private $newPasswordLinkPath = "//a[contains(@href, 'customer/account/createPassword') "
3642
. "and contains(text(), 'Set a New Password')]";
3743

44+
/** @var StoreManagerInterface */
45+
private $storeManager;
46+
47+
/** @var DataFixtureStorage */
48+
private $fixtures;
49+
3850
/**
3951
* @inheritdoc
4052
*/
@@ -45,6 +57,8 @@ protected function setUp(): void
4557
$this->objectManager = Bootstrap::getObjectManager();
4658
$this->accountManagement = $this->objectManager->get(AccountManagementInterface::class);
4759
$this->transportBuilder = $this->objectManager->get(TransportBuilderMock::class);
60+
$this->storeManager = $this->objectManager->get(StoreManagerInterface::class);
61+
$this->fixtures = $this->objectManager->get(DataFixtureStorageManager::class)->getStorage();
4862
}
4963

5064
/**
@@ -61,4 +75,45 @@ public function testForgotPassword(): void
6175
$this->assertTrue($result);
6276
$this->assertEquals(1, Xpath::getElementsCountForXpath($this->newPasswordLinkPath, $messageContent));
6377
}
78+
79+
/**
80+
* @return void
81+
* @throws LocalizedException
82+
*/
83+
#[
84+
DataFixture(Customer::class, ['email' => 'customer@search.example.com'], as: 'customer'),
85+
]
86+
public function testResetPasswordFlowStorefront(): void
87+
{
88+
// Forgot password section;
89+
$customer = $this->fixtures->get('customer');
90+
$email = $customer->getEmail();
91+
$customerId = (int)$customer->getId();
92+
$result = $this->accountManagement->initiatePasswordReset($email, AccountManagement::EMAIL_RESET);
93+
$message = $this->transportBuilder->getSentMessage();
94+
$messageContent = $message->getBody()->getParts()[0]->getRawContent();
95+
$this->assertTrue($result);
96+
$this->assertEquals(1, Xpath::getElementsCountForXpath($this->newPasswordLinkPath, $messageContent));
97+
98+
// Send reset password link
99+
$defaultWebsiteId = (int)$this->storeManager->getWebsite('base')->getId();
100+
$this->accountManagement->initiatePasswordReset($email, AccountManagement::EMAIL_RESET, $defaultWebsiteId);
101+
102+
// login with old credentials
103+
$this->assertEquals(
104+
$customerId,
105+
(int)$this->accountManagement->authenticate($email, 'password')->getId()
106+
);
107+
108+
// Change password
109+
$this->accountManagement->changePassword($email, 'password', 'new_Password123');
110+
111+
// Login with new credentials
112+
$this->accountManagement->authenticate($email, 'new_Password123');
113+
114+
$this->assertEquals(
115+
$customerId,
116+
$this->accountManagement->authenticate($email, 'new_Password123')->getId()
117+
);
118+
}
64119
}

0 commit comments

Comments
 (0)