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

Implement specialized alternatives to assertInternalType() and assertNotInternalType() #3368

Closed
sebastianbergmann opened this Issue Oct 24, 2018 · 6 comments

Comments

Projects
None yet
5 participants
@sebastianbergmann
Copy link
Owner

sebastianbergmann commented Oct 24, 2018

Implement

  • assertIsArray()
  • assertIsBool()
  • assertIsFloat()
  • assertIsInt()
  • assertIsNumeric()
  • assertIsObject()
  • assertIsResource()
  • assertIsString()
  • assertIsScalar()
  • assertIsCallable()
  • assertIsIterable()
  • assertIsNotArray()
  • assertIsNotBool()
  • assertIsNotFloat()
  • assertIsNotInt()
  • assertIsNotNumeric()
  • assertIsNotObject()
  • assertIsNotResource()
  • assertIsNotString()
  • assertIsNotScalar()
  • assertIsNotCallable()
  • assertIsNotIterable()
@keradus

This comment has been minimized.

Copy link
Contributor

keradus commented Oct 25, 2018

can you elaborate on that one, @sebastianbergmann ?
looks like lot of new assertions

I agree that with assertInternalType it's easy to make a typo with provided type, like bol instead of bool, yet even if one would do the typo, then when he run tests assertion will fail anyway

@TomasVotruba

This comment has been minimized.

Copy link
Contributor

TomasVotruba commented Dec 31, 2018

What will happen to same checks just for arrays?

$this->assertContainsOnly('string', $types);

nelson6e65 added a commit to nelson6e65/php_nml that referenced this issue Jan 16, 2019

@glensc

This comment has been minimized.

Copy link

glensc commented Feb 9, 2019

what phpunit min version has the new assertions?

@sebastianbergmann

This comment has been minimized.

Copy link
Owner Author

sebastianbergmann commented Feb 9, 2019

These assertions were implemented for PHPUnit 7.5.

@glensc

This comment has been minimized.

Copy link

glensc commented Feb 9, 2019

what's the replacement for such code:

        $this->assertInternalType(gettype($algo), $res['algo']);
@nelson6e65

This comment has been minimized.

Copy link

nelson6e65 commented Feb 9, 2019

what's the replacement for such code:

        $this->assertInternalType(gettype($algo), $res['algo']);

@glensc Maybe...

$assertIsType = 'assertIs'.gettype($algo);

$this->$assertIsType($res['algo']);

But... if you need this dynamic, you may need a redesign of the test. 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.