Skip to content

Commit f626d3b

Browse files
authored
Merge pull request #3966 from magento-obsessive-owls/MC-5894
[Owls] 2.3 Bug Fix
2 parents 5b912c7 + 8a93614 commit f626d3b

File tree

23 files changed

+127
-74
lines changed

23 files changed

+127
-74
lines changed

app/code/Magento/Braintree/view/frontend/templates/paypal/button.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* @var \Magento\Braintree\Block\Paypal\Button $block
99
*/
1010

11-
$id = $block->getContainerId() . mt_rand();
11+
$id = $block->getContainerId() . random_int(0, PHP_INT_MAX);
1212

1313
$config = [
1414
'Magento_Braintree/js/paypal/button' => [

app/code/Magento/Customer/Test/Unit/Model/AccountManagementTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,8 +1238,7 @@ public function testInitiatePasswordResetEmailReminder()
12381238

12391239
$storeId = 1;
12401240

1241-
mt_srand(mt_rand() + (100000000 * (float)microtime()) % PHP_INT_MAX);
1242-
$hash = md5(uniqid(microtime() . mt_rand(0, mt_getrandmax()), true));
1241+
$hash = hash("sha256", uniqid(microtime() . random_int(0, PHP_INT_MAX), true));
12431242

12441243
$this->emailNotificationMock->expects($this->once())
12451244
->method('passwordReminder')
@@ -1263,8 +1262,7 @@ public function testInitiatePasswordResetEmailReset()
12631262
$templateIdentifier = 'Template Identifier';
12641263
$sender = 'Sender';
12651264

1266-
mt_srand(mt_rand() + (100000000 * (float)microtime()) % PHP_INT_MAX);
1267-
$hash = md5(uniqid(microtime() . mt_rand(0, mt_getrandmax()), true));
1265+
$hash = hash("sha256", uniqid(microtime() . random_int(0, PHP_INT_MAX), true));
12681266

12691267
$this->emailNotificationMock->expects($this->once())
12701268
->method('passwordResetConfirmation')
@@ -1288,8 +1286,7 @@ public function testInitiatePasswordResetNoTemplate()
12881286
$templateIdentifier = 'Template Identifier';
12891287
$sender = 'Sender';
12901288

1291-
mt_srand(mt_rand() + (100000000 * (float)microtime()) % PHP_INT_MAX);
1292-
$hash = md5(uniqid(microtime() . mt_rand(0, mt_getrandmax()), true));
1289+
$hash = hash("sha256", uniqid(microtime() . random_int(0, PHP_INT_MAX), true));
12931290

12941291
$this->prepareInitiatePasswordReset($email, $templateIdentifier, $sender, $storeId, $customerId, $hash);
12951292

dev/tests/api-functional/testsuite/Magento/Customer/Api/GroupRepositoryTest.php

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,6 @@ public function setUp()
5555
$this->customerGroupFactory = $objectManager->create(\Magento\Customer\Api\Data\GroupInterfaceFactory::class);
5656
}
5757

58-
/**
59-
* Execute per test cleanup.
60-
*/
61-
public function tearDown()
62-
{
63-
parent::tearDown();
64-
}
65-
66-
/**
67-
* Cleaning up the extra groups that might have been created as part of the testing.
68-
*/
69-
public static function tearDownAfterClass()
70-
{
71-
parent::tearDownAfterClass();
72-
}
73-
7458
/**
7559
* Verify the retrieval of a customer group by Id.
7660
*
@@ -874,7 +858,7 @@ public function testSearchGroupsDataProvider()
874858
return [
875859
['tax_class_id', 3, []],
876860
['tax_class_id', 0, null],
877-
['code', md5(mt_rand(0, 10000000000) . time()), null],
861+
['code', hash("sha256", random_int(0, 10000000000) . time()), null],
878862
[
879863
'id',
880864
0,

dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Product/CustomOptions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function __construct(
4545

4646
if (isset($data['dataset']) && isset($this->params['repository'])) {
4747
$this->data = $repositoryFactory->get($this->params['repository'])->get($data['dataset']);
48-
$this->data = $this->replaceData($this->data, mt_rand());
48+
$this->data = $this->replaceData($this->data, random_int(0, PHP_INT_MAX));
4949
$this->customOptions = $this->data;
5050
}
5151
if (isset($data['import_products'])) {

dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProduct/ConfigurableAttributesData.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ protected function addVariationMatrix(array $variationsMatrix, array $attribute,
360360

361361
/* If empty matrix add one empty row */
362362
if (empty($variationsMatrix)) {
363-
$variationIsolation = mt_rand(10000, 70000);
363+
$variationIsolation = random_int(10000, 70000);
364364
$variationsMatrix = [
365365
[
366366
'name' => "In configurable product {$variationIsolation}",
@@ -370,7 +370,7 @@ protected function addVariationMatrix(array $variationsMatrix, array $attribute,
370370
}
371371

372372
foreach ($variationsMatrix as $rowKey => $row) {
373-
$randIsolation = mt_rand(1, 100);
373+
$randIsolation = random_int(1, 100);
374374
$rowName = $row['name'];
375375
$rowSku = $row['sku'];
376376
$index = 1;

dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/SearchTermsReportEntityTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function test($product, $countProducts, $countSearch)
9696
*/
9797
protected function createProducts($product, $countProduct)
9898
{
99-
$name = 'simpleProductName' . mt_rand();
99+
$name = 'simpleProductName' . random_int(0, PHP_INT_MAX);
100100
for ($i = 0; $i < $countProduct; $i++) {
101101
$productFixture = $this->fixtureFactory->createByCode(
102102
'catalogProductSimple',

dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/View/SalesTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function setUp()
5353
\Magento\Framework\View\LayoutInterface::class
5454
)->createBlock(
5555
\Magento\Customer\Block\Adminhtml\Edit\Tab\View\Sales::class,
56-
'sales_' . mt_rand(),
56+
'sales_' . random_int(0, PHP_INT_MAX),
5757
['coreRegistry' => $this->coreRegistry]
5858
)->setTemplate(
5959
'tab/view/sales.phtml'

dev/tests/integration/testsuite/Magento/Framework/Model/ResourceModel/Db/ProfilerTest.php

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99

1010
use Magento\Framework\Config\ConfigOptionsListConstants;
1111

12+
/**
13+
* Class ProfilerTest
14+
*/
1215
class ProfilerTest extends \PHPUnit\Framework\TestCase
1316
{
1417
/**
@@ -21,17 +24,27 @@ class ProfilerTest extends \PHPUnit\Framework\TestCase
2124
*/
2225
protected static $_testResourceName = 'testtest_0000_setup';
2326

27+
/**
28+
* @inheritdoc
29+
*
30+
* phpcs:disable Magento2.Functions.StaticFunction
31+
*/
2432
public static function setUpBeforeClass()
2533
{
26-
self::$_testResourceName = 'testtest_' . mt_rand(1000, 9999) . '_setup';
34+
self::$_testResourceName = 'testtest_' . random_int(1000, 9999) . '_setup';
2735

2836
\Magento\Framework\Profiler::enable();
29-
}
37+
} // phpcs:enable
3038

39+
/**
40+
* @inheritdoc
41+
*
42+
* phpcs:disable Magento2.Functions.StaticFunction
43+
*/
3144
public static function tearDownAfterClass()
3245
{
3346
\Magento\Framework\Profiler::disable();
34-
}
47+
} // phpcs:enable
3548

3649
protected function setUp()
3750
{
@@ -126,19 +139,20 @@ public function testProfilerDuringSqlException()
126139
$connection = $this->_getConnection();
127140

128141
try {
129-
$connection->query('SELECT * FROM unknown_table');
142+
$connection->select()->from('unknown_table')->query()->fetch();
130143
} catch (\Zend_Db_Statement_Exception $exception) {
144+
$this->assertNotEmpty($exception);
131145
}
132146

133147
if (!isset($exception)) {
134-
$this->fail("Expected exception didn't thrown!");
148+
$this->fail("Expected exception wasn't thrown!");
135149
}
136150

137151
/** @var \Magento\Framework\App\ResourceConnection $resource */
138152
$resource = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
139153
->get(\Magento\Framework\App\ResourceConnection::class);
140154
$testTableName = $resource->getTableName('setup_module');
141-
$connection->query('SELECT * FROM ' . $testTableName);
155+
$connection->select()->from($testTableName)->query()->fetch();
142156

143157
/** @var \Magento\Framework\Model\ResourceModel\Db\Profiler $profiler */
144158
$profiler = $connection->getProfiler();

dev/tests/integration/testsuite/Magento/Framework/Mview/View/ChangelogTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function testGetVersion()
9595
$model->create();
9696
$this->assertEquals(0, $model->getVersion());
9797
$changelogName = $this->resource->getTableName($model->getName());
98-
$this->connection->insert($changelogName, [$model->getColumnName() => mt_rand(1, 200)]);
98+
$this->connection->insert($changelogName, [$model->getColumnName() => random_int(1, 200)]);
9999
$this->assertEquals($this->connection->lastInsertId($changelogName, 'version_id'), $model->getVersion());
100100
$model->drop();
101101
}

dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/FormTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ protected function setUp()
6868
$layout = $this->objectManager->get(LayoutInterface::class);
6969
$this->block = $layout->createBlock(
7070
Form::class,
71-
'order_create_block' . mt_rand(),
71+
'order_create_block' . random_int(0, PHP_INT_MAX),
7272
['sessionQuote' => $this->session]
7373
);
7474
parent::setUp();

0 commit comments

Comments
 (0)