Fixed isNull in assert
This commit is contained in:
parent
2e12e4f39d
commit
087d50f61b
10 changed files with 34 additions and 34 deletions
|
@ -37,14 +37,14 @@ class Assert
|
||||||
|
|
||||||
public function isNull($actual)
|
public function isNull($actual)
|
||||||
{
|
{
|
||||||
if ($actual !== null and $actual !== false)
|
if ($actual !== null)
|
||||||
$this->fail('Assertion failed. Expected: NULL, got: "' . $actual . '"');
|
$this->fail('Assertion failed. Expected: NULL, got: "' . $this->dumpVar(actual) . '"');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isNotNull($actual)
|
public function isNotNull($actual)
|
||||||
{
|
{
|
||||||
if ($actual === null or $actual === false)
|
if ($actual === null)
|
||||||
$this->fail('Assertion failed. Expected: not NULL, got: "' . $actual . '"');
|
$this->fail('Assertion failed. Expected: not NULL, got: "' . $this->dumpVar(actual) . '"');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isTrue($actual)
|
public function isTrue($actual)
|
||||||
|
|
|
@ -43,7 +43,7 @@ class ActivateUserEmailJobTest extends AbstractTest
|
||||||
UserModel::save($user);
|
UserModel::save($user);
|
||||||
|
|
||||||
$this->assert->areEqual('godzilla@whitestar.gov', $user->getUnconfirmedEmail());
|
$this->assert->areEqual('godzilla@whitestar.gov', $user->getUnconfirmedEmail());
|
||||||
$this->assert->areEqual(null, $user->getConfirmedEmail());
|
$this->assert->isNull($user->getConfirmedEmail());
|
||||||
|
|
||||||
$this->assert->doesNotThrow(function() use ($user)
|
$this->assert->doesNotThrow(function() use ($user)
|
||||||
{
|
{
|
||||||
|
@ -68,7 +68,7 @@ class ActivateUserEmailJobTest extends AbstractTest
|
||||||
//reload local entity after changes done by the job
|
//reload local entity after changes done by the job
|
||||||
$user = UserModel::getById($user->getId());
|
$user = UserModel::getById($user->getId());
|
||||||
|
|
||||||
$this->assert->areEqual(null, $user->getUnconfirmedEmail());
|
$this->assert->isNull($user->getUnconfirmedEmail());
|
||||||
$this->assert->areEqual('godzilla@whitestar.gov', $user->getConfirmedEmail());
|
$this->assert->areEqual('godzilla@whitestar.gov', $user->getConfirmedEmail());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ class ActivateUserEmailJobTest extends AbstractTest
|
||||||
UserModel::save($user);
|
UserModel::save($user);
|
||||||
|
|
||||||
$this->assert->areEqual('godzilla@whitestar.gov', $user->getUnconfirmedEmail());
|
$this->assert->areEqual('godzilla@whitestar.gov', $user->getUnconfirmedEmail());
|
||||||
$this->assert->areEqual(null, $user->getConfirmedEmail());
|
$this->assert->isNull($user->getConfirmedEmail());
|
||||||
|
|
||||||
Api::run(
|
Api::run(
|
||||||
new ActivateUserEmailJob(),
|
new ActivateUserEmailJob(),
|
||||||
|
|
|
@ -58,7 +58,7 @@ class AddPostJobTest extends AbstractTest
|
||||||
file_get_contents($post->getFullPath()),
|
file_get_contents($post->getFullPath()),
|
||||||
file_get_contents($this->testSupport->getPath('image.jpg')));
|
file_get_contents($this->testSupport->getPath('image.jpg')));
|
||||||
$this->assert->areNotEqual(Auth::getCurrentUser()->getId(), $post->getUploaderId());
|
$this->assert->areNotEqual(Auth::getCurrentUser()->getId(), $post->getUploaderId());
|
||||||
$this->assert->areEqual(null, $post->getUploaderId());
|
$this->assert->isNull($post->getUploaderId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPartialPrivilegeFail()
|
public function testPartialPrivilegeFail()
|
||||||
|
|
|
@ -162,7 +162,7 @@ class AddUserJobTest extends AbstractTest
|
||||||
});
|
});
|
||||||
|
|
||||||
//first user = admin = has confirmed e-mail automatically
|
//first user = admin = has confirmed e-mail automatically
|
||||||
$this->assert->areEqual(null, $user1->getUnconfirmedEmail());
|
$this->assert->isNull($user1->getUnconfirmedEmail());
|
||||||
$this->assert->areEqual('godzilla@whitestar.gov', $user1->getConfirmedEmail());
|
$this->assert->areEqual('godzilla@whitestar.gov', $user1->getConfirmedEmail());
|
||||||
|
|
||||||
$user2 = $this->assert->doesNotThrow(function()
|
$user2 = $this->assert->doesNotThrow(function()
|
||||||
|
@ -178,7 +178,7 @@ class AddUserJobTest extends AbstractTest
|
||||||
|
|
||||||
//any other user = non-admin = has to confirmed e-mail manually
|
//any other user = non-admin = has to confirmed e-mail manually
|
||||||
$this->assert->areEqual('godzilla2@whitestar.gov', $user2->getUnconfirmedEmail());
|
$this->assert->areEqual('godzilla2@whitestar.gov', $user2->getUnconfirmedEmail());
|
||||||
$this->assert->areEqual(null, $user2->getConfirmedEmail());
|
$this->assert->isNull($user2->getConfirmedEmail());
|
||||||
|
|
||||||
$this->assert->areEqual(1, Mailer::getMailCounter());
|
$this->assert->areEqual(1, Mailer::getMailCounter());
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,7 @@ class AddUserJobTest extends AbstractTest
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->assert->areEqual('godzilla@whitestar.gov', $user1->getUnconfirmedEmail());
|
$this->assert->areEqual('godzilla@whitestar.gov', $user1->getUnconfirmedEmail());
|
||||||
$this->assert->areEqual(null, $user1->getConfirmedEmail());
|
$this->assert->isNull($user1->getConfirmedEmail());
|
||||||
|
|
||||||
$user2 = $this->assert->doesNotThrow(function()
|
$user2 = $this->assert->doesNotThrow(function()
|
||||||
{
|
{
|
||||||
|
@ -218,7 +218,7 @@ class AddUserJobTest extends AbstractTest
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->assert->areEqual('godzilla2@whitestar.gov', $user2->getUnconfirmedEmail());
|
$this->assert->areEqual('godzilla2@whitestar.gov', $user2->getUnconfirmedEmail());
|
||||||
$this->assert->areEqual(null, $user2->getConfirmedEmail());
|
$this->assert->isNull($user2->getConfirmedEmail());
|
||||||
|
|
||||||
$this->assert->areEqual(2, Mailer::getMailCounter());
|
$this->assert->areEqual(2, Mailer::getMailCounter());
|
||||||
}
|
}
|
||||||
|
@ -243,7 +243,7 @@ class AddUserJobTest extends AbstractTest
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->assert->areEqual(null, $user1->getUnconfirmedEmail());
|
$this->assert->isNull($user1->getUnconfirmedEmail());
|
||||||
$this->assert->areEqual('godzilla@whitestar.gov', $user1->getConfirmedEmail());
|
$this->assert->areEqual('godzilla@whitestar.gov', $user1->getConfirmedEmail());
|
||||||
|
|
||||||
$user2 = $this->assert->doesNotThrow(function()
|
$user2 = $this->assert->doesNotThrow(function()
|
||||||
|
@ -257,7 +257,7 @@ class AddUserJobTest extends AbstractTest
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->assert->areEqual(null, $user2->getUnconfirmedEmail());
|
$this->assert->isNull($user2->getUnconfirmedEmail());
|
||||||
$this->assert->areEqual('godzilla2@whitestar.gov', $user2->getConfirmedEmail());
|
$this->assert->areEqual('godzilla2@whitestar.gov', $user2->getConfirmedEmail());
|
||||||
|
|
||||||
$this->assert->areEqual(0, Mailer::getMailCounter());
|
$this->assert->areEqual(0, Mailer::getMailCounter());
|
||||||
|
|
|
@ -16,7 +16,7 @@ class DeletePostJobTest extends AbstractTest
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->assert->areEqual(null, PostModel::tryGetByName($post->getName()));
|
$this->assert->isNull(PostModel::tryGetByName($post->getName()));
|
||||||
$this->assert->areEqual(0, PostModel::getCount());
|
$this->assert->areEqual(0, PostModel::getCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ class DeleteUserJobTest extends AbstractTest
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->assert->areEqual(null, UserModel::tryGetByName($user->getName()));
|
$this->assert->isNull(UserModel::tryGetByName($user->getName()));
|
||||||
$this->assert->areEqual(0, UserModel::getCount());
|
$this->assert->areEqual(0, UserModel::getCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ class EditUserEmailJobTest extends AbstractTest
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->assert->areEqual(null, $user->getUnconfirmedEmail());
|
$this->assert->isNull($user->getUnconfirmedEmail());
|
||||||
$this->assert->areEqual('xena@other-side.gr', $user->getConfirmedEmail());
|
$this->assert->areEqual('xena@other-side.gr', $user->getConfirmedEmail());
|
||||||
|
|
||||||
$this->assert->areEqual(0, Mailer::getMailCounter());
|
$this->assert->areEqual(0, Mailer::getMailCounter());
|
||||||
|
@ -50,7 +50,7 @@ class EditUserEmailJobTest extends AbstractTest
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->assert->areEqual('xena@other-side.gr', $user->getUnconfirmedEmail());
|
$this->assert->areEqual('xena@other-side.gr', $user->getUnconfirmedEmail());
|
||||||
$this->assert->areEqual(null, $user->getConfirmedEmail());
|
$this->assert->isNull($user->getConfirmedEmail());
|
||||||
|
|
||||||
$this->assert->areEqual(1, Mailer::getMailCounter());
|
$this->assert->areEqual(1, Mailer::getMailCounter());
|
||||||
}
|
}
|
||||||
|
@ -100,8 +100,8 @@ class EditUserEmailJobTest extends AbstractTest
|
||||||
]);
|
]);
|
||||||
}, 'User with this e-mail is already registered');
|
}, 'User with this e-mail is already registered');
|
||||||
|
|
||||||
$this->assert->areEqual(null, $user->getUnconfirmedEmail());
|
$this->assert->isNull($user->getUnconfirmedEmail());
|
||||||
$this->assert->areEqual(null, $user->getConfirmedEmail());
|
$this->assert->isNull($user->getConfirmedEmail());
|
||||||
|
|
||||||
$this->assert->areEqual(0, Mailer::getMailCounter());
|
$this->assert->areEqual(0, Mailer::getMailCounter());
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,6 @@ class FeaturePostJobTest extends AbstractTest
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->assert->areEqual($posts[1]->getId(), PropertyModel::get(PropertyModel::FeaturedPostId));
|
$this->assert->areEqual($posts[1]->getId(), PropertyModel::get(PropertyModel::FeaturedPostId));
|
||||||
$this->assert->areEqual(null, PropertyModel::get(PropertyModel::FeaturedPostUserName));
|
$this->assert->isNull(PropertyModel::get(PropertyModel::FeaturedPostUserName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,12 +25,12 @@ class TextHelperTest extends AbstractTest
|
||||||
$this->assert->areEqual(-2, TextHelper::toIntegerOrNull('-2'));
|
$this->assert->areEqual(-2, TextHelper::toIntegerOrNull('-2'));
|
||||||
$this->assert->areEqual(0, TextHelper::toIntegerOrNull(0));
|
$this->assert->areEqual(0, TextHelper::toIntegerOrNull(0));
|
||||||
$this->assert->areEqual(0, TextHelper::toIntegerOrNull('0'));
|
$this->assert->areEqual(0, TextHelper::toIntegerOrNull('0'));
|
||||||
$this->assert->areEqual(null, TextHelper::toIntegerOrNull('rubbish'));
|
$this->assert->isNull(TextHelper::toIntegerOrNull('rubbish'));
|
||||||
$this->assert->areEqual(null, TextHelper::toIntegerOrNull('1e1'));
|
$this->assert->isNull(TextHelper::toIntegerOrNull('1e1'));
|
||||||
$this->assert->areEqual(null, TextHelper::toIntegerOrNull('1.7'));
|
$this->assert->isNull(TextHelper::toIntegerOrNull('1.7'));
|
||||||
$this->assert->areEqual(null, TextHelper::toIntegerOrNull(true));
|
$this->assert->isNull(TextHelper::toIntegerOrNull(true));
|
||||||
$this->assert->areEqual(null, TextHelper::toIntegerOrNull(false));
|
$this->assert->isNull(TextHelper::toIntegerOrNull(false));
|
||||||
$this->assert->areEqual(null, TextHelper::toIntegerOrNull(null));
|
$this->assert->isNull(TextHelper::toIntegerOrNull(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testToBooleanOrNull()
|
public function testToBooleanOrNull()
|
||||||
|
@ -51,9 +51,9 @@ class TextHelperTest extends AbstractTest
|
||||||
$this->assert->isFalse(TextHelper::toBooleanOrNull('FaLsE'));
|
$this->assert->isFalse(TextHelper::toBooleanOrNull('FaLsE'));
|
||||||
$this->assert->isFalse(TextHelper::toBooleanOrNull('false'));
|
$this->assert->isFalse(TextHelper::toBooleanOrNull('false'));
|
||||||
$this->assert->isFalse(TextHelper::toBooleanOrNull(false));
|
$this->assert->isFalse(TextHelper::toBooleanOrNull(false));
|
||||||
$this->assert->areEqual(null, TextHelper::toBooleanOrNull(2));
|
$this->assert->isNull(TextHelper::toBooleanOrNull(2));
|
||||||
$this->assert->areEqual(null, TextHelper::toBooleanOrNull('2'));
|
$this->assert->isNull(TextHelper::toBooleanOrNull('2'));
|
||||||
$this->assert->areEqual(null, TextHelper::toBooleanOrNull('rubbish'));
|
$this->assert->isNull(TextHelper::toBooleanOrNull('rubbish'));
|
||||||
$this->assert->areEqual(null, TextHelper::toBooleanOrNull(null));
|
$this->assert->isNull(TextHelper::toBooleanOrNull(null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ class PostModelTest extends AbstractTest
|
||||||
return PostModel::getFeaturedPost();
|
return PostModel::getFeaturedPost();
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->assert->areEqual(null, $post);
|
$this->assert->isNull($post);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFeaturingNoPost()
|
public function testFeaturingNoPost()
|
||||||
|
@ -20,7 +20,7 @@ class PostModelTest extends AbstractTest
|
||||||
return PostModel::getFeaturedPost();
|
return PostModel::getFeaturedPost();
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->assert->areEqual(null, $post);
|
$this->assert->isNull($post);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFeaturingRandomPost()
|
public function testFeaturingRandomPost()
|
||||||
|
@ -46,7 +46,7 @@ class PostModelTest extends AbstractTest
|
||||||
|
|
||||||
PostModel::featureRandomPost();
|
PostModel::featureRandomPost();
|
||||||
|
|
||||||
$this->assert->areEqual(null, PropertyModel::get(PropertyModel::FeaturedPostId));
|
$this->assert->isNull(PropertyModel::get(PropertyModel::FeaturedPostId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAutoFeaturingFirstTime()
|
public function testAutoFeaturingFirstTime()
|
||||||
|
|
Loading…
Reference in a new issue