Skip to content

Commit

Permalink
Simplified tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SoftCreatR committed Oct 16, 2018
1 parent 885ecbc commit 54ac4f0
Showing 1 changed file with 6 additions and 23 deletions.
29 changes: 6 additions & 23 deletions tests/SoftCreatR/MimeDetector/MimeDetectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ public function testGetInstance(): void
$mimeDetector = $this->getInstance();

self::assertInstanceOf(MimeDetector::class, $mimeDetector);
self::assertAttributeInternalType('array', 'byteCache', $mimeDetector);
self::assertAttributeInternalType('int', 'byteCacheLen', $mimeDetector);
self::assertAttributeInternalType('string', 'file', $mimeDetector);
self::assertAttributeInternalType('string', 'fileHash', $mimeDetector);
}

/**
Expand All @@ -46,7 +42,7 @@ public function testGetInstance(): void
*/
public function testSetFileThrowsException(): void
{
self::expectException(MimeDetectorException::class);
$this->expectException(MimeDetectorException::class);

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

self::assertAttributeNotEmpty('byteCache', $mimeDetector);
self::assertAttributeGreaterThanOrEqual(1, 'byteCacheLen', $mimeDetector);
self::assertAttributeEquals($testFile['file'], 'file', $mimeDetector);
self::assertAttributeEquals($testFile['hash'], 'fileHash', $mimeDetector);
self::assertAttributeSame($testFile['file'], 'file', $mimeDetector);
self::assertAttributeSame($testFile['hash'], 'fileHash', $mimeDetector);
}
}

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

$fileData = $mimeDetector->getFileType();

self::assertInternalType('array', $fileData);
self::assertEmpty($fileData);
}

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

self::assertInternalType('array', $fileData);
self::assertEmpty($fileData);
}

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

self::assertInternalType('array', $fileData);
self::assertEquals($testFile['ext'], $fileData['ext']);
self::assertSame($testFile['ext'], $fileData['ext']);
}
}

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

self::assertInternalType('string', $detectedExtension);
self::assertEmpty($detectedExtension);
}

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

self::assertInternalType('string', $detectedExtension);
self::assertEquals($testFile['ext'], $detectedExtension);
self::assertSame($testFile['ext'], $detectedExtension);
}
}

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

self::assertInternalType('string', $detectedMimeType);
self::assertEmpty($detectedMimeType);
}

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

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

self::assertInternalType('array', $result);
self::assertEquals([112, 104, 112], $result);
}

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

self::assertInternalType('bool', $result);
self::assertTrue($result);
}

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

self::assertInternalType('int', $result);
self::assertEquals(-1, $result);
}

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

self::assertInternalType('int', $result);
self::assertEquals(2, $result);
}

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

self::assertInternalType('bool', $result);
self::assertFalse($result);
}

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

self::assertInternalType('bool', $result);
self::assertTrue($result);
}

Expand Down Expand Up @@ -344,7 +327,7 @@ public function testCreateByteCacheNull(): void
*/
public function testCreateByteCacheException(): void
{
self::expectException(MimeDetectorException::class);
$this->expectException(MimeDetectorException::class);

$mimeDetector = $this->getInstance();
$mimeDetector->setFile(__FILE__);
Expand Down

0 comments on commit 54ac4f0

Please sign in to comment.