| @@ 8-65 (lines=58) @@ | ||
| 5 | use AlgoWeb\ODataMetadata\MetadataV3\edm\TTypeAnnotationType; |
|
| 6 | use AlgoWeb\ODataMetadata\Tests\TestCase; |
|
| 7 | ||
| 8 | class TAnnotationTypeTest extends TestCase |
|
| 9 | { |
|
| 10 | public function testSetStringNullString() |
|
| 11 | { |
|
| 12 | $foo = new TTypeAnnotationType(); |
|
| 13 | $foo->setString(null); |
|
| 14 | $this->assertEquals(null, $foo->getString()); |
|
| 15 | } |
|
| 16 | ||
| 17 | public function testSetStringActualString() |
|
| 18 | { |
|
| 19 | $foo = new TTypeAnnotationType(); |
|
| 20 | $foo->setString("string"); |
|
| 21 | $this->assertEquals('string', $foo->getString()); |
|
| 22 | } |
|
| 23 | ||
| 24 | public function testSetStringEmptyArrayAsString() |
|
| 25 | { |
|
| 26 | $expected = "String must be a string"; |
|
| 27 | $actual = null; |
|
| 28 | ||
| 29 | $foo = new TTypeAnnotationType(); |
|
| 30 | try { |
|
| 31 | $foo->setString([]); |
|
| 32 | } catch (\InvalidArgumentException $e) { |
|
| 33 | $actual = $e->getMessage(); |
|
| 34 | } |
|
| 35 | $this->assertEquals($expected, $actual); |
|
| 36 | } |
|
| 37 | ||
| 38 | public function testSetStringNonEmptyArrayAsString() |
|
| 39 | { |
|
| 40 | $expected = "String must be a string"; |
|
| 41 | $actual = null; |
|
| 42 | ||
| 43 | $foo = new TTypeAnnotationType(); |
|
| 44 | try { |
|
| 45 | $foo->setString(['a']); |
|
| 46 | } catch (\InvalidArgumentException $e) { |
|
| 47 | $actual = $e->getMessage(); |
|
| 48 | } |
|
| 49 | $this->assertEquals($expected, $actual); |
|
| 50 | } |
|
| 51 | ||
| 52 | public function testSetStringObjectAsString() |
|
| 53 | { |
|
| 54 | $expected = "String must be a string"; |
|
| 55 | $actual = null; |
|
| 56 | ||
| 57 | $foo = new TTypeAnnotationType(); |
|
| 58 | try { |
|
| 59 | $foo->setString(new \DateTime()); |
|
| 60 | } catch (\InvalidArgumentException $e) { |
|
| 61 | $actual = $e->getMessage(); |
|
| 62 | } |
|
| 63 | $this->assertEquals($expected, $actual); |
|
| 64 | } |
|
| 65 | } |
|
| 66 | ||
| @@ 8-65 (lines=58) @@ | ||
| 5 | use AlgoWeb\ODataMetadata\MetadataV3\edm\TOperandType; |
|
| 6 | use AlgoWeb\ODataMetadata\Tests\TestCase; |
|
| 7 | ||
| 8 | class TOperandTypeTest extends TestCase |
|
| 9 | { |
|
| 10 | public function testSetStringNullString() |
|
| 11 | { |
|
| 12 | $foo = new TOperandType(); |
|
| 13 | $foo->setString(null); |
|
| 14 | $this->assertEquals(null, $foo->getString()); |
|
| 15 | } |
|
| 16 | ||
| 17 | public function testSetStringActualString() |
|
| 18 | { |
|
| 19 | $foo = new TOperandType(); |
|
| 20 | $foo->setString("string"); |
|
| 21 | $this->assertEquals('string', $foo->getString()); |
|
| 22 | } |
|
| 23 | ||
| 24 | public function testSetStringEmptyArrayAsString() |
|
| 25 | { |
|
| 26 | $expected = "String must be a string"; |
|
| 27 | $actual = null; |
|
| 28 | ||
| 29 | $foo = new TOperandType(); |
|
| 30 | try { |
|
| 31 | $foo->setString([]); |
|
| 32 | } catch (\InvalidArgumentException $e) { |
|
| 33 | $actual = $e->getMessage(); |
|
| 34 | } |
|
| 35 | $this->assertEquals($expected, $actual); |
|
| 36 | } |
|
| 37 | ||
| 38 | public function testSetStringNonEmptyArrayAsString() |
|
| 39 | { |
|
| 40 | $expected = "String must be a string"; |
|
| 41 | $actual = null; |
|
| 42 | ||
| 43 | $foo = new TOperandType(); |
|
| 44 | try { |
|
| 45 | $foo->setString(['a']); |
|
| 46 | } catch (\InvalidArgumentException $e) { |
|
| 47 | $actual = $e->getMessage(); |
|
| 48 | } |
|
| 49 | $this->assertEquals($expected, $actual); |
|
| 50 | } |
|
| 51 | ||
| 52 | public function testSetStringObjectAsString() |
|
| 53 | { |
|
| 54 | $expected = "String must be a string"; |
|
| 55 | $actual = null; |
|
| 56 | ||
| 57 | $foo = new TOperandType(); |
|
| 58 | try { |
|
| 59 | $foo->setString(new \DateTime()); |
|
| 60 | } catch (\InvalidArgumentException $e) { |
|
| 61 | $actual = $e->getMessage(); |
|
| 62 | } |
|
| 63 | $this->assertEquals($expected, $actual); |
|
| 64 | } |
|
| 65 | } |
|
| 66 | ||
| @@ 8-65 (lines=58) @@ | ||
| 5 | use AlgoWeb\ODataMetadata\MetadataV3\edm\TTypeRefType; |
|
| 6 | use AlgoWeb\ODataMetadata\Tests\TestCase; |
|
| 7 | ||
| 8 | class TTypeRefTypeTest extends TestCase |
|
| 9 | { |
|
| 10 | public function testSetDefaultValueNullString() |
|
| 11 | { |
|
| 12 | $foo = new TTypeRefType(); |
|
| 13 | $foo->setDefaultValue(null); |
|
| 14 | $this->assertEquals(null, $foo->getDefaultValue()); |
|
| 15 | } |
|
| 16 | ||
| 17 | public function testSetDefaultValueActualString() |
|
| 18 | { |
|
| 19 | $foo = new TTypeRefType(); |
|
| 20 | $foo->setDefaultValue("string"); |
|
| 21 | $this->assertEquals('string', $foo->getDefaultValue()); |
|
| 22 | } |
|
| 23 | ||
| 24 | public function testSetDefaultValueEmptyArrayAsString() |
|
| 25 | { |
|
| 26 | $expected = "Default value must be a string"; |
|
| 27 | $actual = null; |
|
| 28 | ||
| 29 | $foo = new TTypeRefType(); |
|
| 30 | try { |
|
| 31 | $foo->setDefaultValue([]); |
|
| 32 | } catch (\InvalidArgumentException $e) { |
|
| 33 | $actual = $e->getMessage(); |
|
| 34 | } |
|
| 35 | $this->assertEquals($expected, $actual); |
|
| 36 | } |
|
| 37 | ||
| 38 | public function testSetDefaultValueNonEmptyArrayAsString() |
|
| 39 | { |
|
| 40 | $expected = "Default value must be a string"; |
|
| 41 | $actual = null; |
|
| 42 | ||
| 43 | $foo = new TTypeRefType(); |
|
| 44 | try { |
|
| 45 | $foo->setDefaultValue(['a']); |
|
| 46 | } catch (\InvalidArgumentException $e) { |
|
| 47 | $actual = $e->getMessage(); |
|
| 48 | } |
|
| 49 | $this->assertEquals($expected, $actual); |
|
| 50 | } |
|
| 51 | ||
| 52 | public function testSetDefaultValueObjectAsString() |
|
| 53 | { |
|
| 54 | $expected = "Default value must be a string"; |
|
| 55 | $actual = null; |
|
| 56 | ||
| 57 | $foo = new TTypeRefType(); |
|
| 58 | try { |
|
| 59 | $foo->setDefaultValue(new \DateTime()); |
|
| 60 | } catch (\InvalidArgumentException $e) { |
|
| 61 | $actual = $e->getMessage(); |
|
| 62 | } |
|
| 63 | $this->assertEquals($expected, $actual); |
|
| 64 | } |
|
| 65 | } |
|
| 66 | ||