|
6 | 6 |
|
7 | 7 | namespace Magento\UrlRewrite\Test\Unit\Model\Storage;
|
8 | 8 |
|
| 9 | +use Magento\Framework\DB\Select; |
9 | 10 | use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
|
10 | 11 | use Magento\UrlRewrite\Model\Storage\DbStorage;
|
11 | 12 | use Magento\UrlRewrite\Service\V1\Data\UrlRewrite;
|
@@ -49,10 +50,9 @@ protected function setUp()
|
49 | 50 | ->disableOriginalConstructor()->getMock();
|
50 | 51 | $this->dataObjectHelper = $this->createMock(\Magento\Framework\Api\DataObjectHelper::class);
|
51 | 52 | $this->connectionMock = $this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class);
|
52 |
| - $this->select = $this->createPartialMock( |
53 |
| - \Magento\Framework\DB\Select::class, |
54 |
| - ['from', 'where', 'deleteFromSelect'] |
55 |
| - ); |
| 53 | + $this->select = $this->getMockBuilder(Select::class) |
| 54 | + ->disableOriginalConstructor() |
| 55 | + ->getMock(); |
56 | 56 | $this->resource = $this->createMock(\Magento\Framework\App\ResourceConnection::class);
|
57 | 57 |
|
58 | 58 | $this->resource->expects($this->any())
|
@@ -447,87 +447,32 @@ public function testReplace()
|
447 | 447 | // delete
|
448 | 448 |
|
449 | 449 | $urlFirst->expects($this->any())
|
450 |
| - ->method('getByKey') |
451 |
| - ->will($this->returnValueMap([ |
452 |
| - [UrlRewrite::ENTITY_TYPE, 'product'], |
453 |
| - [UrlRewrite::ENTITY_ID, 'entity_1'], |
454 |
| - [UrlRewrite::STORE_ID, 'store_id_1'], |
455 |
| - ])); |
456 |
| - $urlFirst->expects($this->any())->method('getEntityType')->willReturn('product'); |
| 450 | + ->method('getEntityType') |
| 451 | + ->willReturn('product'); |
| 452 | + $urlFirst->expects($this->any()) |
| 453 | + ->method('getEntityId') |
| 454 | + ->willReturn('entity_1'); |
| 455 | + $urlFirst->expects($this->any()) |
| 456 | + ->method('getStoreId') |
| 457 | + ->willReturn('store_id_1'); |
| 458 | + |
| 459 | + $urlSecond->expects($this->any()) |
| 460 | + ->method('getEntityType') |
| 461 | + ->willReturn('category'); |
| 462 | + $urlSecond->expects($this->any()) |
| 463 | + ->method('getEntityId') |
| 464 | + ->willReturn('entity_2'); |
457 | 465 | $urlSecond->expects($this->any())
|
458 |
| - ->method('getByKey') |
459 |
| - ->will($this->returnValueMap([ |
460 |
| - [UrlRewrite::ENTITY_TYPE, 'category'], |
461 |
| - [UrlRewrite::ENTITY_ID, 'entity_2'], |
462 |
| - [UrlRewrite::STORE_ID, 'store_id_2'], |
463 |
| - ])); |
464 |
| - $urlSecond->expects($this->any())->method('getEntityType')->willReturn('category'); |
| 466 | + ->method('getStoreId') |
| 467 | + ->willReturn('store_id_2'); |
465 | 468 |
|
466 | 469 | $this->connectionMock->expects($this->any())
|
467 | 470 | ->method('quoteIdentifier')
|
468 | 471 | ->will($this->returnArgument(0));
|
469 | 472 |
|
470 |
| - $this->select->expects($this->at(1)) |
471 |
| - ->method('where') |
472 |
| - ->with('entity_id IN (?)', ['entity_1']); |
473 |
| - |
474 |
| - $this->select->expects($this->at(2)) |
475 |
| - ->method('where') |
476 |
| - ->with('store_id IN (?)', ['store_id_1']); |
477 |
| - |
478 |
| - $this->select->expects($this->at(3)) |
479 |
| - ->method('where') |
480 |
| - ->with('entity_type IN (?)', 'product'); |
481 |
| - |
482 |
| - $this->select->expects($this->at(5)) |
483 |
| - ->method('where') |
484 |
| - ->with('entity_id IN (?)', ['entity_1']); |
485 |
| - |
486 |
| - $this->select->expects($this->at(6)) |
487 |
| - ->method('where') |
488 |
| - ->with('store_id IN (?)', ['store_id_1']); |
489 |
| - |
490 |
| - $this->select->expects($this->at(7)) |
491 |
| - ->method('where') |
492 |
| - ->with('entity_type IN (?)', 'product'); |
493 |
| - |
494 |
| - $this->connectionMock->expects($this->any()) |
495 |
| - ->method('fetchRow') |
496 |
| - ->willReturn(['some-data']); |
497 |
| - |
498 |
| - $this->select->expects($this->at(8)) |
499 |
| - ->method('deleteFromSelect') |
500 |
| - ->with('table_name') |
501 |
| - ->will($this->returnValue('sql delete query')); |
502 |
| - |
503 |
| - $this->select->expects($this->at(10)) |
504 |
| - ->method('where') |
505 |
| - ->with('entity_id IN (?)', ['entity_2']); |
506 |
| - |
507 |
| - $this->select->expects($this->at(11)) |
508 |
| - ->method('where') |
509 |
| - ->with('store_id IN (?)', ['store_id_2']); |
510 |
| - |
511 |
| - $this->select->expects($this->at(12)) |
512 |
| - ->method('where') |
513 |
| - ->with('entity_type IN (?)', 'category'); |
514 |
| - |
515 |
| - $this->select->expects($this->at(14)) |
516 |
| - ->method('where') |
517 |
| - ->with('entity_id IN (?)', ['entity_2']); |
518 |
| - |
519 |
| - $this->select->expects($this->at(15)) |
520 |
| - ->method('where') |
521 |
| - ->with('store_id IN (?)', ['store_id_2']); |
522 |
| - |
523 |
| - $this->select->expects($this->at(16)) |
524 |
| - ->method('where') |
525 |
| - ->with('entity_type IN (?)', 'category'); |
526 |
| - |
527 |
| - $this->select->expects($this->at(17)) |
528 |
| - ->method('deleteFromSelect') |
529 |
| - ->with('table_name') |
530 |
| - ->will($this->returnValue('sql delete query')); |
| 473 | + $this->select->expects($this->any()) |
| 474 | + ->method($this->anything()) |
| 475 | + ->willReturnSelf(); |
531 | 476 |
|
532 | 477 | $this->resource->expects($this->any())
|
533 | 478 | ->method('getTableName')
|
|
0 commit comments