Skip to content

Commit 54ac4f0

Browse files
committed
Simplified tests
1 parent 885ecbc commit 54ac4f0

File tree

1 file changed

+6
-23
lines changed

1 file changed

+6
-23
lines changed

tests/SoftCreatR/MimeDetector/MimeDetectorTest.php

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ public function testGetInstance(): void
3232
$mimeDetector = $this->getInstance();
3333

3434
self::assertInstanceOf(MimeDetector::class, $mimeDetector);
35-
self::assertAttributeInternalType('array', 'byteCache', $mimeDetector);
36-
self::assertAttributeInternalType('int', 'byteCacheLen', $mimeDetector);
37-
self::assertAttributeInternalType('string', 'file', $mimeDetector);
38-
self::assertAttributeInternalType('string', 'fileHash', $mimeDetector);
3935
}
4036

4137
/**
@@ -46,7 +42,7 @@ public function testGetInstance(): void
4642
*/
4743
public function testSetFileThrowsException(): void
4844
{
49-
self::expectException(MimeDetectorException::class);
45+
$this->expectException(MimeDetectorException::class);
5046

5147
$mimeDetector = MimeDetector::getInstance();
5248
$mimeDetector->setFile('nonexistant.file');
@@ -67,8 +63,8 @@ public function testSetFile($testFiles): void
6763

6864
self::assertAttributeNotEmpty('byteCache', $mimeDetector);
6965
self::assertAttributeGreaterThanOrEqual(1, 'byteCacheLen', $mimeDetector);
70-
self::assertAttributeEquals($testFile['file'], 'file', $mimeDetector);
71-
self::assertAttributeEquals($testFile['hash'], 'fileHash', $mimeDetector);
66+
self::assertAttributeSame($testFile['file'], 'file', $mimeDetector);
67+
self::assertAttributeSame($testFile['hash'], 'fileHash', $mimeDetector);
7268
}
7369
}
7470

@@ -90,7 +86,6 @@ public function testGetFileTypeReturnEmptyArrayWithoutByteCache(): void
9086

9187
$fileData = $mimeDetector->getFileType();
9288

93-
self::assertInternalType('array', $fileData);
9489
self::assertEmpty($fileData);
9590
}
9691

@@ -106,7 +101,6 @@ public function testGetFileTypeReturnEmptyArrayWithUnknownFileType(): void
106101
$mimeDetector->setFile(__FILE__);
107102
$fileData = $mimeDetector->getFileType();
108103

109-
self::assertInternalType('array', $fileData);
110104
self::assertEmpty($fileData);
111105
}
112106

@@ -124,8 +118,7 @@ public function testGetFileType(array $testFiles): void
124118
$mimeDetector->setFile($testFile['file']);
125119
$fileData = $mimeDetector->getFileType();
126120

127-
self::assertInternalType('array', $fileData);
128-
self::assertEquals($testFile['ext'], $fileData['ext']);
121+
self::assertSame($testFile['ext'], $fileData['ext']);
129122
}
130123
}
131124

@@ -142,7 +135,6 @@ public function testGetFileExtensionEmpty(): void
142135
$mimeDetector->setFile(__FILE__);
143136
$detectedExtension = $mimeDetector->getFileExtension();
144137

145-
self::assertInternalType('string', $detectedExtension);
146138
self::assertEmpty($detectedExtension);
147139
}
148140

@@ -160,8 +152,7 @@ public function testGetFileExtension(array $testFiles): void
160152
$mimeDetector->setFile($testFile['file']);
161153
$detectedExtension = $mimeDetector->getFileExtension();
162154

163-
self::assertInternalType('string', $detectedExtension);
164-
self::assertEquals($testFile['ext'], $detectedExtension);
155+
self::assertSame($testFile['ext'], $detectedExtension);
165156
}
166157
}
167158

@@ -178,7 +169,6 @@ public function testGetMimeTypeEmpty(): void
178169
$mimeDetector->setFile(__FILE__);
179170
$detectedMimeType = $mimeDetector->getMimeType();
180171

181-
self::assertInternalType('string', $detectedMimeType);
182172
self::assertEmpty($detectedMimeType);
183173
}
184174

@@ -197,7 +187,6 @@ public function testGetMimeType(array $testFiles): void
197187
$detectedMimeType = $mimeDetector->getMimeType();
198188

199189
// we don't know the mime type of our test file, so we'll just check, if any mimetype has been detected
200-
self::assertInternalType('string', $detectedMimeType);
201190
self::assertNotEmpty($detectedMimeType);
202191
}
203192
}
@@ -230,7 +219,6 @@ public function testToBytes(): void
230219
$mimeDetector = $this->getInstance();
231220
$result = $mimeDetector->toBytes('php');
232221

233-
self::assertInternalType('array', $result);
234222
self::assertEquals([112, 104, 112], $result);
235223
}
236224

@@ -246,7 +234,6 @@ public function testCheckString(): void
246234
$method = MimeDetectorTestUtil::getProtectedMethod($mimeDetector, 'checkString');
247235
$result = $method->invoke($mimeDetector, 'php', 2);
248236

249-
self::assertInternalType('bool', $result);
250237
self::assertTrue($result);
251238
}
252239

@@ -264,7 +251,6 @@ public function testSearchForBytesNegative(): void
264251
$method = MimeDetectorTestUtil::getProtectedMethod($mimeDetector, 'searchForBytes');
265252
$result = $method->invoke($mimeDetector, [0x66, 0x6F, 0x6F]); // foo
266253

267-
self::assertInternalType('int', $result);
268254
self::assertEquals(-1, $result);
269255
}
270256

@@ -280,7 +266,6 @@ public function testSearchForBytes(): void
280266
$method = MimeDetectorTestUtil::getProtectedMethod($mimeDetector, 'searchForBytes');
281267
$result = $method->invoke($mimeDetector, [0x70, 0x68, 0x70]); // php
282268

283-
self::assertInternalType('int', $result);
284269
self::assertEquals(2, $result);
285270
}
286271

@@ -298,7 +283,6 @@ public function testCheckForBytesFalse(): void
298283
$method = MimeDetectorTestUtil::getProtectedMethod($mimeDetector, 'checkForBytes');
299284
$result = $method->invoke($mimeDetector, []);
300285

301-
self::assertInternalType('bool', $result);
302286
self::assertFalse($result);
303287
}
304288

@@ -314,7 +298,6 @@ public function testCheckForBytes(): void
314298
$method = MimeDetectorTestUtil::getProtectedMethod($mimeDetector, 'checkForBytes');
315299
$result = $method->invoke($mimeDetector, [0x70, 0x68, 0x70], 2); // php
316300

317-
self::assertInternalType('bool', $result);
318301
self::assertTrue($result);
319302
}
320303

@@ -344,7 +327,7 @@ public function testCreateByteCacheNull(): void
344327
*/
345328
public function testCreateByteCacheException(): void
346329
{
347-
self::expectException(MimeDetectorException::class);
330+
$this->expectException(MimeDetectorException::class);
348331

349332
$mimeDetector = $this->getInstance();
350333
$mimeDetector->setFile(__FILE__);

0 commit comments

Comments
 (0)