FactoryTest.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Backup\Test\Unit;
  7. class FactoryTest extends \PHPUnit\Framework\TestCase
  8. {
  9. /**
  10. * @var \Magento\Framework\Backup\Factory
  11. */
  12. protected $_model;
  13. /**
  14. * @var \Magento\Framework\ObjectManagerInterface
  15. */
  16. protected $_objectManager;
  17. protected function setUp()
  18. {
  19. $this->_objectManager = $this->createMock(\Magento\Framework\ObjectManagerInterface::class);
  20. $this->_model = new \Magento\Framework\Backup\Factory($this->_objectManager);
  21. }
  22. /**
  23. * @expectedException \Magento\Framework\Exception\LocalizedException
  24. */
  25. public function testCreateWrongType()
  26. {
  27. $this->_model->create('WRONG_TYPE');
  28. }
  29. /**
  30. * @param string $type
  31. * @dataProvider allowedTypesDataProvider
  32. */
  33. public function testCreate($type)
  34. {
  35. $this->_objectManager->expects($this->once())->method('create')->will($this->returnValue('ModelInstance'));
  36. $this->assertEquals('ModelInstance', $this->_model->create($type));
  37. }
  38. /**
  39. * @return array
  40. */
  41. public function allowedTypesDataProvider()
  42. {
  43. return [['db'], ['snapshot'], ['filesystem'], ['media'], ['nomedia']];
  44. }
  45. }