AttributeValueTest.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Api\Test\Unit\Data;
  7. use Magento\Framework\Api\AttributeValue;
  8. class AttributeValueTest extends \PHPUnit\Framework\TestCase
  9. {
  10. const ATTRIBUTE_CODE = 'ATTRIBUTE_CODE';
  11. const STRING_VALUE = 'VALUE';
  12. const INTEGER_VALUE = 1;
  13. const FLOAT_VALUE = 1.0;
  14. const BOOLEAN_VALUE = true;
  15. public function testConstructorAndGettersWithString()
  16. {
  17. $attribute = new AttributeValue(
  18. [
  19. AttributeValue::ATTRIBUTE_CODE => self::ATTRIBUTE_CODE,
  20. AttributeValue::VALUE => self::STRING_VALUE
  21. ]
  22. );
  23. $this->assertSame(self::ATTRIBUTE_CODE, $attribute->getAttributeCode());
  24. $this->assertSame(self::STRING_VALUE, $attribute->getValue());
  25. }
  26. public function testConstructorAndGettersWithInteger()
  27. {
  28. $attribute = new AttributeValue(
  29. [
  30. AttributeValue::ATTRIBUTE_CODE => self::ATTRIBUTE_CODE,
  31. AttributeValue::VALUE => self::INTEGER_VALUE
  32. ]
  33. );
  34. $this->assertSame(self::ATTRIBUTE_CODE, $attribute->getAttributeCode());
  35. $this->assertSame(self::INTEGER_VALUE, $attribute->getValue());
  36. }
  37. public function testConstructorAndGettersWithFloat()
  38. {
  39. $attribute = new AttributeValue(
  40. [
  41. AttributeValue::ATTRIBUTE_CODE => self::ATTRIBUTE_CODE,
  42. AttributeValue::VALUE => self::FLOAT_VALUE
  43. ]
  44. );
  45. $this->assertSame(self::ATTRIBUTE_CODE, $attribute->getAttributeCode());
  46. $this->assertSame(self::FLOAT_VALUE, $attribute->getValue());
  47. }
  48. public function testConstructorAndGettersWithBoolean()
  49. {
  50. $attribute = new AttributeValue(
  51. [
  52. AttributeValue::ATTRIBUTE_CODE => self::ATTRIBUTE_CODE,
  53. AttributeValue::VALUE => self::BOOLEAN_VALUE
  54. ]
  55. );
  56. $this->assertSame(self::ATTRIBUTE_CODE, $attribute->getAttributeCode());
  57. $this->assertSame(self::BOOLEAN_VALUE, $attribute->getValue());
  58. }
  59. }