![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/cartforge.co/vendor/paypal/module-braintree-core/Test/Unit/Helper/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace PayPal\Braintree\Test\Unit\Helper; use PayPal\Braintree\Helper\Country; use Magento\Directory\Model\ResourceModel\Country\CollectionFactory; use Magento\Directory\Model\ResourceModel\Country\Collection; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; class CountryTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Directory\Model\ResourceModel\Country\Collection|\PHPUnit\Framework\MockObject\MockObject */ private $collection; /** * @var \PayPal\Braintree\Helper\Country */ private $helper; /** * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager */ private $objectManager; protected function setUp(): void { $this->objectManager = new ObjectManager($this); $collectionFactory = $this->getCollectionFactoryMock(); $this->helper = $this->objectManager->getObject(Country::class, [ 'factory' => $collectionFactory ]); } /** * @covers \PayPal\Braintree\Helper\Country::getCountries */ public function testGetCountries() { $this->collection->expects(static::once()) ->method('toOptionArray') ->willReturn([ ['value' => 'US', 'label' => 'United States'], ['value' => 'UK', 'label' => 'United Kingdom'], ]); $this->helper->getCountries(); $this->collection->expects(static::never()) ->method('toOptionArray'); $this->helper->getCountries(); } /** * Create mock for country collection factory */ protected function getCollectionFactoryMock() { $this->collection = $this->getMockBuilder(Collection::class) ->disableOriginalConstructor() ->setMethods(['addFieldToFilter', 'loadData', 'toOptionArray', '__wakeup']) ->getMock(); $this->collection->expects(static::any()) ->method('addFieldToFilter') ->willReturnSelf(); $this->collection->expects(static::any()) ->method('loadData') ->willReturnSelf(); $collectionFactory = $this->getMockBuilder(CollectionFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); $collectionFactory->expects(static::once()) ->method('create') ->willReturn($this->collection); return $collectionFactory; } }