CollectionTest.php 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. /**
  7. * Tests for customer addresses collection
  8. */
  9. namespace Magento\Customer\Model\ResourceModel\Address;
  10. class CollectionTest extends \PHPUnit\Framework\TestCase
  11. {
  12. public function testSetCustomerFilter()
  13. {
  14. $collection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
  15. \Magento\Customer\Model\ResourceModel\Address\Collection::class
  16. );
  17. $select = $collection->getSelect();
  18. $this->assertSame($collection, $collection->setCustomerFilter([1, 2]));
  19. $customer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
  20. \Magento\Customer\Model\Customer::class
  21. );
  22. $collection->setCustomerFilter($customer);
  23. $customer->setId(3);
  24. $collection->setCustomerFilter($customer);
  25. $this->assertStringMatchesFormat(
  26. '%AWHERE%S(%Sparent_id%S IN(%S1%S, %S2%S))%SAND%S(%Sparent_id%S = %S-1%S)%SAND%S(%Sparent_id%S = %S3%S)%A',
  27. (string)$select
  28. );
  29. }
  30. }