get(Collection::class); $expectedResult = []; /** @var $taxRate Rate */ foreach ($collection as $taxRate) { $expectedResult[] = ['value' => $taxRate->getId(), 'label' => $taxRate->getCode()]; if (count($expectedResult) >= $optionsCount) { break; } } /** @var Source $source */ if (empty($expectedResult)) { $this->fail('Preconditions failed: At least one tax rate should be available.'); } $provider = $objectManager->get(Provider::class); /** @var SearchCriteriaBuilder $searchCriteriaBuilder */ $searchCriteriaBuilder = $objectManager->create(SearchCriteriaBuilder::class); $searchCriteriaBuilder->setPageSize($optionsCount); $searchCriteriaBuilder->setCurrentPage(1); $searchCriteria = $searchCriteriaBuilder->create(); $this->assertEquals( $expectedResult, $provider->toOptionArray($searchCriteria), 'Tax rate options are invalid.' ); } }