FactoryTest.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Message;
  7. /**
  8. * \Magento\Framework\Message\Factory test case
  9. */
  10. class FactoryTest extends \PHPUnit\Framework\TestCase
  11. {
  12. /**
  13. * @var \Magento\Framework\Message\Factory
  14. */
  15. protected $model;
  16. /**
  17. * @var \Magento\Framework\ObjectManagerInterface
  18. */
  19. protected $objectManager;
  20. public function setUp()
  21. {
  22. $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
  23. $this->model = $this->objectManager->create(\Magento\Framework\Message\Factory::class);
  24. }
  25. /**
  26. * @dataProvider createProvider
  27. */
  28. public function testCreate($messageType)
  29. {
  30. $message = $this->model->create($messageType, 'some text');
  31. $this->assertInstanceOf(\Magento\Framework\Message\MessageInterface::class, $message);
  32. }
  33. public function createProvider()
  34. {
  35. return [
  36. [MessageInterface::TYPE_SUCCESS],
  37. [MessageInterface::TYPE_NOTICE],
  38. [MessageInterface::TYPE_WARNING],
  39. [MessageInterface::TYPE_ERROR]
  40. ];
  41. }
  42. /**
  43. * @expectedException \InvalidArgumentException
  44. * @expectedExceptionMessage Wrong message type
  45. */
  46. public function testCreateWrong()
  47. {
  48. $this->model->create('Wrong', 'some text');
  49. }
  50. }