4
4
namespace JsonApiPhp \JsonApi \Test \Document \Resource ;
5
5
6
6
use JsonApiPhp \JsonApi \Document \Meta ;
7
- use JsonApiPhp \JsonApi \Document \Resource \Relationship \ Relationship ;
7
+ use JsonApiPhp \JsonApi \Document \Resource \Relationship ;
8
8
use JsonApiPhp \JsonApi \Document \Resource \ResourceObject ;
9
9
use PHPUnit \Framework \TestCase ;
10
10
@@ -23,7 +23,7 @@ class ResourceFieldsTest extends TestCase
23
23
{
24
24
/**
25
25
* @expectedException \LogicException
26
- * @expectedExceptionMessage Field foo already exists in attributes
26
+ * @expectedExceptionMessage Field ' foo' already exists in attributes
27
27
*/
28
28
public function testCanNotSetRelationshipIfAttributeExists ()
29
29
{
@@ -34,7 +34,7 @@ public function testCanNotSetRelationshipIfAttributeExists()
34
34
35
35
/**
36
36
* @expectedException \LogicException
37
- * @expectedExceptionMessage Field foo already exists in relationships
37
+ * @expectedExceptionMessage Field ' foo' already exists in relationships
38
38
*/
39
39
public function testCanNotSetAttributeIfRelationshipExists ()
40
40
{
@@ -67,65 +67,11 @@ public function testRelationshipCanNotHaveReservedNames(string $name)
67
67
$ res ->setRelationship ($ name , Relationship::fromMeta (Meta::fromArray (['a ' => 'b ' ])));
68
68
}
69
69
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
-
93
70
public function reservedAttributeNames (): array
94
71
{
95
72
return [
96
73
['id ' ],
97
74
['type ' ],
98
75
];
99
76
}
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
- }
131
77
}
0 commit comments