public function testToOptionArray() { $this->_importConfig->expects($this->once())->method('getAvailableServices')->will($this->returnValue(['service_one', 'service_two'])); $this->_importConfig->expects($this->at(1))->method('getServiceLabel')->with('service_one')->will($this->returnValue('Service One')); $this->_importConfig->expects($this->at(2))->method('getServiceLabel')->with('service_two')->will($this->returnValue('Service Two')); $expectedResult = [['value' => 'service_one', 'label' => 'Service One'], ['value' => 'service_two', 'label' => 'Service Two']]; $this->assertEquals($expectedResult, $this->_model->toOptionArray()); // Makes sure the value is calculated only once $this->assertEquals($expectedResult, $this->_model->toOptionArray()); }
/** * @expectedException \UnexpectedValueException * @expectedExceptionMessage Class 'stdClass' has to implement * \Magento\Directory\Model\Currency\Import\ImportInterface */ public function testCreateIrrelevantServiceClass() { $this->_importConfig->expects($this->once())->method('getServiceClass')->with('test')->will($this->returnValue('stdClass')); $this->_objectManager->expects($this->once())->method('create')->with('stdClass')->will($this->returnValue(new \stdClass())); $this->_model->create('test'); }