Skip to content

Commit

Permalink
Update UtilityTest.php
Browse files Browse the repository at this point in the history
  • Loading branch information
ericsizemore committed Dec 8, 2023
1 parent fa9b866 commit 905c751
Showing 1 changed file with 25 additions and 66 deletions.
91 changes: 25 additions & 66 deletions tests/src/UtilityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -376,12 +376,9 @@ public function testRandomBytes(): void
$bytes = Utility::randomBytes(8);
$this->assertNotEmpty($bytes);

try {
$this->expectException(\Random\RandomException::class);
$bytes = Utility::randomBytes(0);
} finally {
//
}
$this->expectException(\Random\RandomException::class);
$bytes = Utility::randomBytes(0);

}

/**
Expand All @@ -392,15 +389,11 @@ public function testRandomInt(): void
$int = Utility::randomInt(100, 250);
$this->assertTrue(($int >= 100 and $int <= 250));

try {
$this->expectException(\Random\RandomException::class);
$int = Utility::randomInt(intval(\PHP_INT_MIN - 1), \PHP_INT_MAX);

$this->expectException(\Random\RandomException::class);
$int = Utility::randomInt(\PHP_INT_MAX, \PHP_INT_MIN);
} finally {
//
}
$this->expectException(\Random\RandomException::class);
$int = Utility::randomInt(\intval(\PHP_INT_MIN - 1), \PHP_INT_MAX);
$int = Utility::randomInt(\PHP_INT_MAX, \PHP_INT_MIN);

}

/**
Expand All @@ -411,12 +404,9 @@ public function testRandomString(): void
$str = Utility::randomString(16);
$this->assertTrue(Utility::length($str) === 16);

try {
$this->expectException(\Random\RandomException::class);
$str = Utility::randomString(-10);
} finally {
//
}
$this->expectException(\Random\RandomException::class);
$str = Utility::randomString(-10);

}

/**
Expand All @@ -429,12 +419,8 @@ public function testLineCounter(): void
$this->assertEquals(0, \array_sum(Utility::lineCounter(directory: self::$testDir, ignore: ['dir1'], onlyLineCount: true)));
Utility::fileWrite(self::$testFiles['file1'], '');

try {
$this->expectException(\InvalidArgumentException::class);
$count = \array_sum(Utility::lineCounter('/this/should/not/exist', onlyLineCount: true));
} finally {
//
}
$this->expectException(\InvalidArgumentException::class);
$count = \array_sum(Utility::lineCounter('/this/should/not/exist', onlyLineCount: true));
}

/**
Expand All @@ -451,12 +437,8 @@ public function testDirectorySize(): void
Utility::fileWrite(self::$testFiles['file1'], '');
Utility::fileWrite(self::$testFiles['file2'], '');

try {
$this->expectException(\InvalidArgumentException::class);
$count = Utility::directorySize('/this/should/not/exist');
} finally {
//
}
$this->expectException(\InvalidArgumentException::class);
$count = Utility::directorySize('/this/should/not/exist');
}

/**
Expand All @@ -482,12 +464,8 @@ public function testDirectoryList(): void
Utility::fileWrite(self::$testFiles['file1'], '');
Utility::fileWrite(self::$testFiles['file2'], '');

try {
$this->expectException(\InvalidArgumentException::class);
$count = Utility::directoryList('/this/should/not/exist');
} finally {
//
}
$this->expectException(\InvalidArgumentException::class);
$count = Utility::directoryList('/this/should/not/exist');
}

/**
Expand Down Expand Up @@ -520,12 +498,8 @@ public function testFileRead(): void

Utility::fileWrite(self::$testFiles['file1'], '');

try {
$this->expectException(\InvalidArgumentException::class);
$read = Utility::fileRead(self::$testFiles['file1'] . '.php');
} finally {
//
}
$this->expectException(\InvalidArgumentException::class);
$read = Utility::fileRead(self::$testFiles['file1'] . '.php');
}

/**
Expand All @@ -537,12 +511,8 @@ public function testFileWrite(): void

Utility::fileWrite(self::$testFiles['file1'], '');

try {
$this->expectException(\InvalidArgumentException::class);
$read = Utility::fileWrite(self::$testFiles['file1'] . '.php');
} finally {
//
}
$this->expectException(\InvalidArgumentException::class);
$read = Utility::fileWrite(self::$testFiles['file1'] . '.php');
}

/**
Expand Down Expand Up @@ -723,16 +693,9 @@ public function testTimeDifference(): void

$this->assertEquals('1 second(s) old', Utility::timeDifference(\time() - 1, 0, ''));

try {
$this->expectException(\InvalidArgumentException::class);
$time = Utility::timeDifference(\time() - 30, 0, 'INVALID');

$this->expectException(\InvalidArgumentException::class);
$time = Utility::timeDifference(-8400, 0);
} finally {
//
}

$this->expectException(\InvalidArgumentException::class);
$time = Utility::timeDifference(\time() - 30, 0, 'INVALID');
$time = Utility::timeDifference(-8400, 0);
}

/**
Expand Down Expand Up @@ -803,12 +766,8 @@ public function testObscureEmail(): void
Utility::obscureEmail('[email protected]')
);

try {
$this->expectException(\InvalidArgumentException::class);
$email = Utility::obscureEmail('thisisnotvalid&!--');
} finally {
//
}
$this->expectException(\InvalidArgumentException::class);
$email = Utility::obscureEmail('thisisnotvalid&!--');
}

/**
Expand Down

0 comments on commit 905c751

Please sign in to comment.