コード例 #1
0
ファイル: LabelTest.php プロジェクト: aiesh/magento2
 /**
  * @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));
 }
コード例 #2
0
ファイル: LabelTest.php プロジェクト: Doability/magento2dev
 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']);
 }
コード例 #3
0
ファイル: Label.php プロジェクト: Doability/magento2dev
 /**
  * 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;
 }
コード例 #4
0
ファイル: Theme.php プロジェクト: aiesh/magento2
 /**
  * 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);
 }