/** * @covers \Magento\Framework\View\Design\Theme\Label::getLabelsCollection */ public function testGetLabelsCollection() { /** @var $expectedCollection \Magento\Core\Model\Resource\Theme\Collection */ $expectedCollection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Framework\\View\\Design\\Theme\\Label\\ListInterface'); $expectedItemsCount = count($expectedCollection->getLabels()); $labelsCollection = $this->_model->getLabelsCollection(); $this->assertEquals($expectedItemsCount, count($labelsCollection)); $labelsCollection = $this->_model->getLabelsCollection('-- Please Select --'); $this->assertEquals(++$expectedItemsCount, count($labelsCollection)); }
/** * Return labels collection array * * @param bool|string $label add empty values to result with specific label * @return array */ public function getLabelsCollection($label = false) { $options = parent::getLabelsCollection(); if ($label) { array_unshift($options, ['value' => 0, 'label' => $label]); } return $options; }
/** * Retrieve All Design Theme Options * * @param bool $withEmpty add empty (please select) values to result * @return Label[] */ public function getAllOptions($withEmpty = true) { $label = $withEmpty ? __('-- Please Select --') : $withEmpty; return $this->_options = $this->themeLabel->getLabelsCollection($label); }