/** * @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)); }
public function testGetLabelsCollectionForSystemConfiguration() { $defaultLabel = (string) new \Magento\Framework\Phrase('-- No Theme --'); $data = ['value' => '1', 'label' => 'Label1']; $this->labelList->expects($this->once())->method('getLabels')->willReturn([$data]); $result = $this->model->getLabelsCollectionForSystemConfiguration(); $this->assertTrue(is_array($result)); $this->assertEquals(2, count($result)); $this->assertEquals($defaultLabel, $result[0]['label']); $this->assertEquals($data['label'], $result[1]['label']); }
/** * 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); }