Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write Some Assertions for Validation Library #10582

Merged
merged 6 commits into from Apr 27, 2017

Conversation

sohelrana820
Copy link
Contributor

No description provided.

@markstory markstory added this to the 3.4.6 milestone Apr 24, 2017
@@ -2813,6 +2817,9 @@ public function testContainNonAlphaNumeric()
$this->assertFalse(Validation::containsNonAlphaNumeric('abcdef##', 3));
$this->assertFalse(Validation::containsNonAlphaNumeric('abc##def', 3));
$this->assertFalse(Validation::containsNonAlphaNumeric('ab#cd#ef', 3));

//CHECK SCALAR
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these comments in ALL CAPS?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No special reason. Should I make it capitalize or lowercase?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need them at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so. Cause someone might be mistakenly tried with Scalar value (CC or AlphaNumeric).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But arent you doing the opposite here? Checking a non-scalar (array) value?
Usually one can make a separate test method with the method name making it clear, also optionally adding a doc block note there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, what do you suggest here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

testContainNonAlphaNumericWithArray() etc for example.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK... Please do me a favor. I will do something like that you said. So should I send another pull request after modify it? And If so then what about my current pull request?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can add commits to your branch. This PR will automatically be updated :)

@codecov-io
Copy link

codecov-io commented Apr 24, 2017

Codecov Report

Merging #10582 into master will increase coverage by 0.02%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #10582      +/-   ##
============================================
+ Coverage     94.86%   94.89%   +0.02%     
  Complexity    12101    12101              
============================================
  Files           422      422              
  Lines         30073    30072       -1     
============================================
+ Hits          28530    28537       +7     
+ Misses         1543     1535       -8
Impacted Files Coverage Δ Complexity Δ
src/Routing/RouteCollection.php 100% <0%> (ø) 25% <0%> (ø) ⬇️
src/Validation/Validation.php 94.67% <0%> (+0.81%) 237% <0%> (ø) ⬇️
src/Cache/Engine/FileEngine.php 86.59% <0%> (+1.11%) 72% <0%> (ø) ⬇️
src/Cache/CacheEngine.php 93.47% <0%> (+2.17%) 19% <0%> (ø) ⬇️
src/Cache/CacheRegistry.php 100% <0%> (+4.16%) 11% <0%> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 04e2fbb...9a010d0. Read the comment docs.

@@ -3104,4 +3099,10 @@ public function testImageWidth()
$this->assertFalse(Validation::imageWidth($upload, '>', 2000));
$this->assertFalse(Validation::imageWidth($upload, '==', 3000));
}

public function testContainNonAlphaNumericAndCCWithScalar()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why scalar? Those are non scalar values - also the 2nd one is not the same as in the previous commit (it now is a scalar).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will fix it.

@@ -168,6 +168,7 @@ public function testLengthBetween()

$this->assertFalse(Validation::lengthBetween('abcdefg', 1, 6));
$this->assertFalse(Validation::lengthBetween('ÆΔΩЖÇ', 1, 3));
$this->assertFalse(Validation::lengthBetween(1, 1, 3));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this should be true actually - is there maybe a cast missing? Or are we ok with the string input only for it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No casting issue. It's just take string input.

public function testContainNonAlphaNumericAndCCWithScalar()
{
$this->assertFalse(Validation::cc(['869972521242198'], ['voyager']));
$this->assertFalse(Validation::containsNonAlphaNumeric('ab#cd#ef', 3));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this here vs. with the other tests for this method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So...What do you suggest?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests could be added to the existing test methods.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK... I will modify it.

@dereuromark
Copy link
Member

I am still not sure any of the tests brings value. They are either covered or completely out of scope (passing an array never works by definition).

@markstory markstory self-assigned this Apr 26, 2017
@markstory markstory merged commit 2c30c3f into cakephp:master Apr 27, 2017
@markstory
Copy link
Member

Thanks @sohelrana820

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants