*/
public function testCheckKeys($function, $expected)
{
- $function_exists = $this->getFunctionMock(__NAMESPACE__, 'function_exists');
+ $function_exists = $this->getFunctionMock('Friendica\Core', 'function_exists');
$function_exists->expects($this->any())->willReturnCallback(function($function_name) use ($function, $expected) {
if ($function_name === $function) {
return $expected;
*/
public function testCheckFunctionsWithoutIntlChar()
{
- $class_exists = $this->getFunctionMock(__NAMESPACE__, 'class_exists');
+ $class_exists = $this->getFunctionMock('Friendica\Core', 'class_exists');
$class_exists->expects($this->any())->willReturnCallback(function($class_name) {
if ($class_name === 'IntlChar') {
return false;
*/
public function testCheckFunctionsWithoutCurlInit()
{
- $function_exists = $this->getFunctionMock(__NAMESPACE__, 'function_exists');
+ $function_exists = $this->getFunctionMock('Friendica\Core', 'function_exists');
$function_exists->expects($this->any())->willReturnCallback(function($function_name) {
if ($function_name === 'curl_init') {
return false;
*/
public function testCheckFunctionsWithoutImagecreateformjpeg()
{
- $function_exists = $this->getFunctionMock(__NAMESPACE__, 'function_exists');
+ $function_exists = $this->getFunctionMock('Friendica\Core', 'function_exists');
$function_exists->expects($this->any())->willReturnCallback(function($function_name) {
if ($function_name === 'imagecreatefromjpeg') {
return false;
*/
public function testCheckFunctionsWithoutOpensslpublicencrypt()
{
- $function_exists = $this->getFunctionMock(__NAMESPACE__, 'function_exists');
+ $function_exists = $this->getFunctionMock('Friendica\Core', 'function_exists');
$function_exists->expects($this->any())->willReturnCallback(function($function_name) {
if ($function_name === 'openssl_public_encrypt') {
return false;
*/
public function testCheckFunctionsWithoutMbStrlen()
{
- $function_exists = $this->getFunctionMock(__NAMESPACE__, 'function_exists');
+ $function_exists = $this->getFunctionMock('Friendica\Core', 'function_exists');
$function_exists->expects($this->any())->willReturnCallback(function($function_name) {
if ($function_name === 'mb_strlen') {
return false;
*/
public function testCheckFunctionsWithoutIconvStrlen()
{
- $function_exists = $this->getFunctionMock(__NAMESPACE__, 'function_exists');
+ $function_exists = $this->getFunctionMock('Friendica\Core', 'function_exists');
$function_exists->expects($this->any())->willReturnCallback(function($function_name) {
if ($function_name === 'iconv_strlen') {
return false;
*/
public function testCheckFunctionsWithoutPosixkill()
{
- $function_exists = $this->getFunctionMock(__NAMESPACE__, 'function_exists');
+ $function_exists = $this->getFunctionMock('Friendica\Core', 'function_exists');
$function_exists->expects($this->any())->willReturnCallback(function($function_name) {
if ($function_name === 'posix_kill') {
return false;
*/
public function testCheckFunctionsWithoutProcOpen()
{
- $function_exists = $this->getFunctionMock(__NAMESPACE__, 'function_exists');
+ $function_exists = $this->getFunctionMock('Friendica\Core', 'function_exists');
$function_exists->expects($this->any())->willReturnCallback(function($function_name) {
if ($function_name === 'proc_open') {
return false;
*/
public function testCheckFunctionsWithoutJsonEncode()
{
- $function_exists = $this->getFunctionMock(__NAMESPACE__, 'function_exists');
+ $function_exists = $this->getFunctionMock('Friendica\Core', 'function_exists');
$function_exists->expects($this->any())->willReturnCallback(function($function_name) {
if ($function_name === 'json_encode') {
return false;
*/
public function testCheckFunctionsWithoutFinfoOpen()
{
- $function_exists = $this->getFunctionMock(__NAMESPACE__, 'function_exists');
+ $function_exists = $this->getFunctionMock('Friendica\Core', 'function_exists');
$function_exists->expects($this->any())->willReturnCallback(function($function_name) {
if ($function_name === 'finfo_open') {
return false;
*/
public function testCheckFunctionsWithoutGmpStrval()
{
- $function_exists = $this->getFunctionMock(__NAMESPACE__, 'function_exists');
+ $function_exists = $this->getFunctionMock('Friendica\Core', 'function_exists');
$function_exists->expects($this->any())->willReturnCallback(function($function_name) {
if ($function_name === 'gmp_strval') {
return false;
*/
public function testCheckFunctions()
{
- $function_exists = $this->getFunctionMock(__NAMESPACE__, 'function_exists');
+ $function_exists = $this->getFunctionMock('Friendica\Core', 'function_exists');
$function_exists->expects($this->any())->willReturnCallback(function($function_name) {
if (in_array(
$function_name,
public function testCheckHtAccessFail()
{
// Mocking that we can use CURL
- $function_exists = $this->getFunctionMock(__NAMESPACE__, 'function_exists');
+ $function_exists = $this->getFunctionMock('Friendica\Core', 'function_exists');
$function_exists->expects($this->any())->willReturnCallback(function($function_name) {
if ($function_name === 'curl_init') {
return true;
public function testCheckHtAccessWork()
{
// Mocking that we can use CURL
- $function_exists = $this->getFunctionMock(__NAMESPACE__, 'function_exists');
+ $function_exists = $this->getFunctionMock('Friendica\Core', 'function_exists');
$function_exists->expects($this->any())->willReturnCallback(function($function_name) {
if ($function_name === 'curl_init') {
return true;
*/
public function testCheckImagickWithImagick()
{
- $class_exists = $this->getFunctionMock(__NAMESPACE__, 'class_exists');
+ $class_exists = $this->getFunctionMock('Friendica\Core', 'class_exists');
$class_exists->expects($this->any())->willReturnCallback(function($class_name) {
if ($class_name === 'Imagick') {
return true;
parent::tearDownAfterClass();
}
- /**
- * Replaces random_int results with given mocks
- *
- */
- private function assertRandomInt($min, $max)
- {
- global $phpMock;
- $phpMock['random_int'] = function ($mMin, $mMax) use ($min, $max) {
- self::assertEquals($min, $mMin);
- self::assertEquals($max, $mMax);
- return 1;
- };
- }
-
public function testRandomDigitsRandomInt()
{
- $random_int = $this->getFunctionMock(__NAMESPACE__, 'random_int');
+ $random_int = $this->getFunctionMock('Friendica\Util', 'random_int');
$random_int->expects($this->any())->willReturnCallback(function($min, $max) {
- global $phpMock;
- if (isset($phpMock['random_int'])) {
- return call_user_func_array($phpMock['random_int'], func_get_args());
- }
+ return 1;
});
- self::assertRandomInt(0, 9);
-
- $test = Crypto::randomDigits(1);
- self::assertEquals(1, strlen($test));
- self::assertEquals(1, $test);
-
- $test = Crypto::randomDigits(8);
- self::assertEquals(8, strlen($test));
- self::assertEquals(11111111, $test);
+ self::assertSame(1, Crypto::randomDigits(1));
+ self::assertSame(11111111, Crypto::randomDigits(8));
}
public function dataRsa(): array
*/
public function testPubRsaToMe(string $key, string $expected)
{
- self::assertEquals($expected, Crypto::rsaToPem(base64_decode($key)));
+ self::assertSame($expected, Crypto::rsaToPem(base64_decode($key)));
}