@@ -50,13 +50,11 @@ protected function removeDirectory($directory)
50
50
rmdir ($ directory );
51
51
}
52
52
53
- /**
54
- * @covers Symfony\Component\Config\Resource\DirectoryResource::getResource
55
- */
56
53
public function testGetResource ()
57
54
{
58
55
$ resource = new DirectoryResource ($ this ->directory );
59
- $ this ->assertEquals ($ this ->directory , $ resource ->getResource (), '->getResource() returns the path to the resource ' );
56
+ $ this ->assertSame ($ this ->directory , $ resource ->getResource (), '->getResource() returns the path to the resource ' );
57
+ $ this ->assertSame ($ this ->directory , (string ) $ resource , '->__toString() returns the path to the resource ' );
60
58
}
61
59
62
60
public function testGetPattern ()
@@ -65,9 +63,6 @@ public function testGetPattern()
65
63
$ this ->assertEquals ('bar ' , $ resource ->getPattern ());
66
64
}
67
65
68
- /**
69
- * @covers Symfony\Component\Config\Resource\DirectoryResource::isFresh
70
- */
71
66
public function testIsFresh ()
72
67
{
73
68
$ resource = new DirectoryResource ($ this ->directory );
@@ -78,49 +73,34 @@ public function testIsFresh()
78
73
$ this ->assertFalse ($ resource ->isFresh (time ()), '->isFresh() returns false if the resource does not exist ' );
79
74
}
80
75
81
- /**
82
- * @covers Symfony\Component\Config\Resource\DirectoryResource::isFresh
83
- */
84
76
public function testIsFreshUpdateFile ()
85
77
{
86
78
$ resource = new DirectoryResource ($ this ->directory );
87
79
touch ($ this ->directory .'/tmp.xml ' , time () + 20 );
88
80
$ this ->assertFalse ($ resource ->isFresh (time () + 10 ), '->isFresh() returns false if an existing file is modified ' );
89
81
}
90
82
91
- /**
92
- * @covers Symfony\Component\Config\Resource\DirectoryResource::isFresh
93
- */
94
83
public function testIsFreshNewFile ()
95
84
{
96
85
$ resource = new DirectoryResource ($ this ->directory );
97
86
touch ($ this ->directory .'/new.xml ' , time () + 20 );
98
87
$ this ->assertFalse ($ resource ->isFresh (time () + 10 ), '->isFresh() returns false if a new file is added ' );
99
88
}
100
89
101
- /**
102
- * @covers Symfony\Component\Config\Resource\DirectoryResource::isFresh
103
- */
104
90
public function testIsFreshDeleteFile ()
105
91
{
106
92
$ resource = new DirectoryResource ($ this ->directory );
107
93
unlink ($ this ->directory .'/tmp.xml ' );
108
94
$ this ->assertFalse ($ resource ->isFresh (time ()), '->isFresh() returns false if an existing file is removed ' );
109
95
}
110
96
111
- /**
112
- * @covers Symfony\Component\Config\Resource\DirectoryResource::isFresh
113
- */
114
97
public function testIsFreshDeleteDirectory ()
115
98
{
116
99
$ resource = new DirectoryResource ($ this ->directory );
117
100
$ this ->removeDirectory ($ this ->directory );
118
101
$ this ->assertFalse ($ resource ->isFresh (time ()), '->isFresh() returns false if the whole resource is removed ' );
119
102
}
120
103
121
- /**
122
- * @covers Symfony\Component\Config\Resource\DirectoryResource::isFresh
123
- */
124
104
public function testIsFreshCreateFileInSubdirectory ()
125
105
{
126
106
$ subdirectory = $ this ->directory .'/subdirectory ' ;
@@ -133,9 +113,6 @@ public function testIsFreshCreateFileInSubdirectory()
133
113
$ this ->assertFalse ($ resource ->isFresh (time () + 10 ), '->isFresh() returns false if a new file in a subdirectory is added ' );
134
114
}
135
115
136
- /**
137
- * @covers Symfony\Component\Config\Resource\DirectoryResource::isFresh
138
- */
139
116
public function testIsFreshModifySubdirectory ()
140
117
{
141
118
$ resource = new DirectoryResource ($ this ->directory );
@@ -147,9 +124,6 @@ public function testIsFreshModifySubdirectory()
147
124
$ this ->assertFalse ($ resource ->isFresh (time () + 10 ), '->isFresh() returns false if a subdirectory is modified (e.g. a file gets deleted) ' );
148
125
}
149
126
150
- /**
151
- * @covers Symfony\Component\Config\Resource\DirectoryResource::isFresh
152
- */
153
127
public function testFilterRegexListNoMatch ()
154
128
{
155
129
$ resource = new DirectoryResource ($ this ->directory , '/\.(foo|xml)$/ ' );
@@ -158,14 +132,21 @@ public function testFilterRegexListNoMatch()
158
132
$ this ->assertTrue ($ resource ->isFresh (time () + 10 ), '->isFresh() returns true if a new file not matching the filter regex is created ' );
159
133
}
160
134
161
- /**
162
- * @covers Symfony\Component\Config\Resource\DirectoryResource::isFresh
163
- */
164
135
public function testFilterRegexListMatch ()
165
136
{
166
137
$ resource = new DirectoryResource ($ this ->directory , '/\.(foo|xml)$/ ' );
167
138
168
139
touch ($ this ->directory .'/new.xml ' , time () + 20 );
169
140
$ this ->assertFalse ($ resource ->isFresh (time () + 10 ), '->isFresh() returns false if an new file matching the filter regex is created ' );
170
141
}
142
+
143
+ public function testSerializeUnserialize ()
144
+ {
145
+ $ resource = new DirectoryResource ($ this ->directory , '/\.(foo|xml)$/ ' );
146
+
147
+ $ unserialized = unserialize (serialize ($ resource ));
148
+
149
+ $ this ->assertSame ($ this ->directory , $ resource ->getResource ());
150
+ $ this ->assertSame ('/\.(foo|xml)$/ ' , $ resource ->getPattern ());
151
+ }
171
152
}
0 commit comments