44namespace JsonApiPhp \JsonApi \Test \Document \Resource ;
55
66use JsonApiPhp \JsonApi \Document \Meta ;
7- use JsonApiPhp \JsonApi \Document \Resource \Relationship \ Relationship ;
7+ use JsonApiPhp \JsonApi \Document \Resource \Relationship ;
88use JsonApiPhp \JsonApi \Document \Resource \ResourceObject ;
99use PHPUnit \Framework \TestCase ;
1010
@@ -23,7 +23,7 @@ class ResourceFieldsTest extends TestCase
2323{
2424 /**
2525 * @expectedException \LogicException
26- * @expectedExceptionMessage Field foo already exists in attributes
26+ * @expectedExceptionMessage Field ' foo' already exists in attributes
2727 */
2828 public function testCanNotSetRelationshipIfAttributeExists ()
2929 {
@@ -34,7 +34,7 @@ public function testCanNotSetRelationshipIfAttributeExists()
3434
3535 /**
3636 * @expectedException \LogicException
37- * @expectedExceptionMessage Field foo already exists in relationships
37+ * @expectedExceptionMessage Field ' foo' already exists in relationships
3838 */
3939 public function testCanNotSetAttributeIfRelationshipExists ()
4040 {
@@ -67,65 +67,11 @@ public function testRelationshipCanNotHaveReservedNames(string $name)
6767 $ res ->setRelationship ($ name , Relationship::fromMeta (Meta::fromArray (['a ' => 'b ' ])));
6868 }
6969
70- /**
71- * @param string $name
72- * @expectedException \OutOfBoundsException
73- * @expectedExceptionMessage Not a valid attribute name
74- * @dataProvider invalidAttributeNames
75- */
76- public function testAttributeNameIsNotValid (string $ name )
77- {
78- $ res = new ResourceObject ('books ' , 'abc ' );
79- $ res ->setAttribute ($ name , 1 );
80- }
81-
82- /**
83- * @param string $name
84- * @dataProvider validAttributeNames
85- */
86- public function testAttributeNameIsValid (string $ name )
87- {
88- $ res = new ResourceObject ('books ' , 'abc ' );
89- $ res ->setAttribute ($ name , 1 );
90- $ this ->assertTrue (true );
91- }
92-
9370 public function reservedAttributeNames (): array
9471 {
9572 return [
9673 ['id ' ],
9774 ['type ' ],
9875 ];
9976 }
100-
101- public function invalidAttributeNames (): array
102- {
103- return [
104- ['_abcde ' ],
105- ['abcd_ ' ],
106- ['abc$EDS ' ],
107- ['#abcde ' ],
108- ['abcde( ' ],
109- ['b_ ' ],
110- ['_a ' ],
111- ['$ab_c-d ' ],
112- ['-abc ' ],
113- ];
114- }
115-
116- public function validAttributeNames (): array
117- {
118- return [
119- ['abcd ' ],
120- ['abcA4C ' ],
121- ['abc_d3f45 ' ],
122- ['abd_eca ' ],
123- ['a ' ],
124- ['b ' ],
125- ['ab ' ],
126- ['a-bc_de ' ],
127- ['abcéêçèÇ_n ' ],
128- ['abc 汉字 abc ' ],
129- ];
130- }
13177}
0 commit comments