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

Deprecate assertions (and helper methods) that operate on (non-public) attributes #3338

Closed
sebastianbergmann opened this issue Oct 11, 2018 · 9 comments
Assignees
Milestone

Comments

@sebastianbergmann
Copy link
Owner

@sebastianbergmann sebastianbergmann commented Oct 11, 2018

The following methods should be deprecated:

  • assertAttributeContains()
  • assertAttributeNotContains()
  • assertAttributeContainsOnly()
  • assertAttributeNotContainsOnly()
  • assertAttributeCount()
  • assertAttributeNotCount()
  • assertAttributeEquals()
  • assertAttributeNotEquals()
  • assertAttributeEmpty()
  • assertAttributeNotEmpty()
  • assertAttributeGreaterThan()
  • assertAttributeGreaterThanOrEqual()
  • assertAttributeLessThan()
  • assertAttributeLessThanOrEqual()
  • assertAttributeSame()
  • assertAttributeNotSame()
  • assertAttributeInstanceOf()
  • assertAttributeNotInstanceOf()
  • assertAttributeInternalType()
  • assertAttributeNotInternalType()
  • attribute()
  • attributeEqualTo()
  • readAttribute()
  • getStaticAttribute()
  • getObjectAttribute
@sebastianbergmann sebastianbergmann added this to the PHPUnit 8.0 milestone Oct 11, 2018
@sebastianbergmann sebastianbergmann self-assigned this Oct 11, 2018
@sebastianbergmann sebastianbergmann changed the title Deprecate assertions that operate on (non-public) attributes Deprecate assertions (and helper methods) that operate on (non-public) attributes Oct 11, 2018
@TomasVotruba
Copy link
Contributor

@TomasVotruba TomasVotruba commented Dec 10, 2018

What should be used instead?

@gmponos
Copy link

@gmponos gmponos commented Dec 10, 2018

@TomasVotruba
Copy link
Contributor

@TomasVotruba TomasVotruba commented Dec 10, 2018

@gmponos Thanks!

@l0gicgate l0gicgate mentioned this issue Feb 19, 2019
3 of 3 tasks complete
malukenho added a commit to malukenho/ProxyManager that referenced this issue Feb 27, 2019
- Remove unnecessary assertions
- Avoid using deprecated assertions
(sebastianbergmann/phpunit#3338)

Signed-off-by: Jefersson Nathan <malukenho.dev@gmail.com>
malukenho added a commit to malukenho/ProxyManager that referenced this issue Feb 27, 2019
* Remove unnecessary assertions

* Avoid using deprecated assertions
  (sebastianbergmann/phpunit#3338)

* Add more entropy when needed

* Use static methods whenever possible
  (providers, test cases that don't access object context)

Signed-off-by: Jefersson Nathan <malukenho.dev@gmail.com>
malukenho added a commit to malukenho/ProxyManager that referenced this issue Feb 27, 2019
* Remove unnecessary assertions

* Avoid using deprecated assertions
  (sebastianbergmann/phpunit#3338)

* Add more entropy when needed

* Use static methods whenever possible
  (providers, test cases that don't access object context)

Signed-off-by: Jefersson Nathan <malukenho.dev@gmail.com>
malukenho added a commit to malukenho/ProxyManager that referenced this issue Feb 27, 2019
* Remove unnecessary assertions

* Avoid using deprecated assertions
  (sebastianbergmann/phpunit#3338)

* Add more entropy when needed

* Use static methods whenever possible
  (providers, test cases that don't access object context)

Signed-off-by: Jefersson Nathan <malukenho.dev@gmail.com>
malukenho added a commit to malukenho/ProxyManager that referenced this issue Feb 27, 2019
* Remove unnecessary assertions

* Avoid using deprecated assertions
  (sebastianbergmann/phpunit#3338)

* Add more entropy when needed

* Use static methods whenever possible
  (providers, test cases that don't access object context)

Signed-off-by: Jefersson Nathan <malukenho.dev@gmail.com>
@geoidesic
Copy link

@geoidesic geoidesic commented Mar 4, 2020

How do I figure out what replaces these?

@sebastianbergmann
Copy link
Owner Author

@sebastianbergmann sebastianbergmann commented Mar 4, 2020

@geoidesic There is no replacement. The correct course of action is to refactor your code to not require dirty tricks like this.

@aogg
Copy link

@aogg aogg commented Aug 6, 2020

@geoidesic There is no replacement. The correct course of action is to refactor your code to not require dirty tricks like this.

why not

stronk7 added a commit to stronk7/moodle that referenced this issue Aug 31, 2020
With PHPUnit 8 a good number of assertions, all them related with
operations on non-public attributes have been deprecated. And will
be removed with PHPUnit 9.

The main point is that unit tests shouldn't be testing non-public
APIs (good practice) and those assertions were an error originally.

See sebastianbergmann/phpunit#3338 for
the complete list and other details.

When possible (the attributes being checked are public), the change
is simple, just switching to normal assertions.

When the attributes are not public we need to find a workaround
to be able to test the same using public APIs, or use Reflection,
or remove the tests.

For the records, this is the regexp used to find all the cases:

ag '>(assertAttribute|attribute\(|readAttributte|getStaticAttribute| \
    getObjectAttribute)' -G "test.php"
stronk7 added a commit to stronk7/moodle that referenced this issue Sep 2, 2020
With PHPUnit 8 a good number of assertions, all them related with
operations on non-public attributes have been deprecated. And will
be removed with PHPUnit 9.

The main point is that unit tests shouldn't be testing non-public
APIs (good practice) and those assertions were an error originally.

See sebastianbergmann/phpunit#3338 for
the complete list and other details.

When possible (the attributes being checked are public), the change
is simple, just switching to normal assertions.

When the attributes are not public we need to find a workaround
to be able to test the same using public APIs, or use Reflection,
or remove the tests.

For the records, this is the regexp used to find all the cases:

ag '>(assertAttribute|attribute\(|readAttributte|getStaticAttribute| \
    getObjectAttribute)' -G "test.php"
stronk7 added a commit to stronk7/moodle that referenced this issue Sep 3, 2020
With PHPUnit 8 a good number of assertions, all them related with
operations on non-public attributes have been deprecated. And will
be removed with PHPUnit 9.

The main point is that unit tests shouldn't be testing non-public
APIs (good practice) and those assertions were an error originally.

See sebastianbergmann/phpunit#3338 for
the complete list and other details.

When possible (the attributes being checked are public), the change
is simple, just switching to normal assertions.

When the attributes are not public we need to find a workaround
to be able to test the same using public APIs, or use Reflection,
or remove the tests.

For the records, this is the regexp used to find all the cases:

ag '>(assertAttribute|attribute\(|readAttributte|getStaticAttribute| \
    getObjectAttribute)' -G "test.php"
stronk7 added a commit to stronk7/moodle that referenced this issue Sep 10, 2020
With PHPUnit 8 a good number of assertions, all them related with
operations on non-public attributes have been deprecated. And will
be removed with PHPUnit 9.

The main point is that unit tests shouldn't be testing non-public
APIs (good practice) and those assertions were an error originally.

See sebastianbergmann/phpunit#3338 for
the complete list and other details.

When possible (the attributes being checked are public), the change
is simple, just switching to normal assertions.

When the attributes are not public we need to find a workaround
to be able to test the same using public APIs, or use Reflection,
or remove the tests.

For the records, this is the regexp used to find all the cases:

ag '>(assertAttribute|attribute\(|readAttributte|getStaticAttribute| \
    getObjectAttribute)' -G "test.php"
stronk7 added a commit to stronk7/moodle that referenced this issue Sep 12, 2020
With PHPUnit 8 a good number of assertions, all them related with
operations on non-public attributes have been deprecated. And will
be removed with PHPUnit 9.

The main point is that unit tests shouldn't be testing non-public
APIs (good practice) and those assertions were an error originally.

See sebastianbergmann/phpunit#3338 for
the complete list and other details.

When possible (the attributes being checked are public), the change
is simple, just switching to normal assertions.

When the attributes are not public we need to find a workaround
to be able to test the same using public APIs, or use Reflection,
or remove the tests.

For the records, this is the regexp used to find all the cases:

ag '>(assertAttribute|attribute\(|readAttributte|getStaticAttribute| \
    getObjectAttribute)' -G "test.php"
stronk7 added a commit to stronk7/moodle that referenced this issue Sep 15, 2020
With PHPUnit 8 a good number of assertions, all them related with
operations on non-public attributes have been deprecated. And will
be removed with PHPUnit 9.

The main point is that unit tests shouldn't be testing non-public
APIs (good practice) and those assertions were an error originally.

See sebastianbergmann/phpunit#3338 for
the complete list and other details.

When possible (the attributes being checked are public), the change
is simple, just switching to normal assertions.

When the attributes are not public we need to find a workaround
to be able to test the same using public APIs, or use Reflection,
or remove the tests.

For the records, this is the regexp used to find all the cases:

ag '>(assertAttribute|attribute\(|readAttributte|getStaticAttribute| \
    getObjectAttribute)' -G "test.php"
stronk7 added a commit to stronk7/moodle that referenced this issue Sep 15, 2020
With PHPUnit 8 a good number of assertions, all them related with
operations on non-public attributes have been deprecated. And will
be removed with PHPUnit 9.

The main point is that unit tests shouldn't be testing non-public
APIs (good practice) and those assertions were an error originally.

See sebastianbergmann/phpunit#3338 for
the complete list and other details.

When possible (the attributes being checked are public), the change
is simple, just switching to normal assertions.

When the attributes are not public we need to find a workaround
to be able to test the same using public APIs, or use Reflection,
or remove the tests.

For the records, this is the regexp used to find all the cases:

ag '>(assertAttribute|attribute\(|readAttributte|getStaticAttribute| \
    getObjectAttribute)' -G "test.php"
stronk7 added a commit to stronk7/moodle that referenced this issue Sep 15, 2020
With PHPUnit 8 a good number of assertions, all them related with
operations on non-public attributes have been deprecated. And will
be removed with PHPUnit 9.

The main point is that unit tests shouldn't be testing non-public
APIs (good practice) and those assertions were an error originally.

See sebastianbergmann/phpunit#3338 for
the complete list and other details.

When possible (the attributes being checked are public), the change
is simple, just switching to normal assertions.

When the attributes are not public we need to find a workaround
to be able to test the same using public APIs, or use Reflection,
or remove the tests.

For the records, this is the regexp used to find all the cases:

ag '>(assertAttribute|attribute\(|readAttributte|getStaticAttribute| \
    getObjectAttribute)' -G "test.php"
stronk7 added a commit to stronk7/moodle that referenced this issue Sep 17, 2020
With PHPUnit 8 a good number of assertions, all them related with
operations on non-public attributes have been deprecated. And will
be removed with PHPUnit 9.

The main point is that unit tests shouldn't be testing non-public
APIs (good practice) and those assertions were an error originally.

See sebastianbergmann/phpunit#3338 for
the complete list and other details.

When possible (the attributes being checked are public), the change
is simple, just switching to normal assertions.

When the attributes are not public we need to find a workaround
to be able to test the same using public APIs, or use Reflection,
or remove the tests.

For the records, this is the regexp used to find all the cases:

ag '>(assertAttribute|attribute\(|readAttributte|getStaticAttribute| \
    getObjectAttribute)' -G "test.php"
stronk7 added a commit to stronk7/moodle that referenced this issue Sep 20, 2020
With PHPUnit 8 a good number of assertions, all them related with
operations on non-public attributes have been deprecated. And will
be removed with PHPUnit 9.

The main point is that unit tests shouldn't be testing non-public
APIs (good practice) and those assertions were an error originally.

See sebastianbergmann/phpunit#3338 for
the complete list and other details.

When possible (the attributes being checked are public), the change
is simple, just switching to normal assertions.

When the attributes are not public we need to find a workaround
to be able to test the same using public APIs, or use Reflection,
or remove the tests.

For the records, this is the regexp used to find all the cases:

ag '>(assertAttribute|attribute\(|readAttributte|getStaticAttribute| \
    getObjectAttribute)' -G "test.php"
stronk7 added a commit to stronk7/moodle that referenced this issue Sep 24, 2020
With PHPUnit 8 a good number of assertions, all them related with
operations on non-public attributes have been deprecated. And will
be removed with PHPUnit 9.

The main point is that unit tests shouldn't be testing non-public
APIs (good practice) and those assertions were an error originally.

See sebastianbergmann/phpunit#3338 for
the complete list and other details.

When possible (the attributes being checked are public), the change
is simple, just switching to normal assertions.

When the attributes are not public we need to find a workaround
to be able to test the same using public APIs, or use Reflection,
or remove the tests.

For the records, this is the regexp used to find all the cases:

ag '>(assertAttribute|attribute\(|readAttributte|getStaticAttribute| \
    getObjectAttribute)' -G "test.php"
stronk7 added a commit to stronk7/moodle that referenced this issue Sep 29, 2020
With PHPUnit 8 a good number of assertions, all them related with
operations on non-public attributes have been deprecated. And will
be removed with PHPUnit 9.

The main point is that unit tests shouldn't be testing non-public
APIs (good practice) and those assertions were an error originally.

See sebastianbergmann/phpunit#3338 for
the complete list and other details.

When possible (the attributes being checked are public), the change
is simple, just switching to normal assertions.

When the attributes are not public we need to find a workaround
to be able to test the same using public APIs, or use Reflection,
or remove the tests.

For the records, this is the regexp used to find all the cases:

ag '>(assertAttribute|attribute\(|readAttributte|getStaticAttribute| \
    getObjectAttribute)' -G "test.php"
stronk7 added a commit to stronk7/moodle that referenced this issue Oct 2, 2020
With PHPUnit 8 a good number of assertions, all them related with
operations on non-public attributes have been deprecated. And will
be removed with PHPUnit 9.

The main point is that unit tests shouldn't be testing non-public
APIs (good practice) and those assertions were an error originally.

See sebastianbergmann/phpunit#3338 for
the complete list and other details.

When possible (the attributes being checked are public), the change
is simple, just switching to normal assertions.

When the attributes are not public we need to find a workaround
to be able to test the same using public APIs, or use Reflection,
or remove the tests.

For the records, this is the regexp used to find all the cases:

ag '>(assertAttribute|attribute\(|readAttributte|getStaticAttribute| \
    getObjectAttribute)' -G "test.php"
stronk7 added a commit to stronk7/moodle that referenced this issue Oct 7, 2020
With PHPUnit 8 a good number of assertions, all them related with
operations on non-public attributes have been deprecated. And will
be removed with PHPUnit 9.

The main point is that unit tests shouldn't be testing non-public
APIs (good practice) and those assertions were an error originally.

See sebastianbergmann/phpunit#3338 for
the complete list and other details.

When possible (the attributes being checked are public), the change
is simple, just switching to normal assertions.

When the attributes are not public we need to find a workaround
to be able to test the same using public APIs, or use Reflection,
or remove the tests.

For the records, this is the regexp used to find all the cases:

ag '>(assertAttribute|attribute\(|readAttributte|getStaticAttribute| \
    getObjectAttribute)' -G "test.php"
stronk7 added a commit to stronk7/moodle that referenced this issue Oct 7, 2020
With PHPUnit 8 a good number of assertions, all them related with
operations on non-public attributes have been deprecated. And will
be removed with PHPUnit 9.

The main point is that unit tests shouldn't be testing non-public
APIs (good practice) and those assertions were an error originally.

See sebastianbergmann/phpunit#3338 for
the complete list and other details.

When possible (the attributes being checked are public), the change
is simple, just switching to normal assertions.

When the attributes are not public we need to find a workaround
to be able to test the same using public APIs, or use Reflection,
or remove the tests.

For the records, this is the regexp used to find all the cases:

ag '>(assertAttribute|attribute\(|readAttributte|getStaticAttribute| \
    getObjectAttribute)' -G "test.php"
stronk7 added a commit to stronk7/moodle that referenced this issue Oct 7, 2020
With PHPUnit 8 a good number of assertions, all them related with
operations on non-public attributes have been deprecated. And will
be removed with PHPUnit 9.

The main point is that unit tests shouldn't be testing non-public
APIs (good practice) and those assertions were an error originally.

See sebastianbergmann/phpunit#3338 for
the complete list and other details.

When possible (the attributes being checked are public), the change
is simple, just switching to normal assertions.

When the attributes are not public we need to find a workaround
to be able to test the same using public APIs, or use Reflection,
or remove the tests.

For the records, this is the regexp used to find all the cases:

ag '>(assertAttribute|attribute\(|readAttributte|getStaticAttribute| \
    getObjectAttribute)' -G "test.php"
stronk7 added a commit to stronk7/moodle that referenced this issue Oct 9, 2020
With PHPUnit 8 a good number of assertions, all them related with
operations on non-public attributes have been deprecated. And will
be removed with PHPUnit 9.

The main point is that unit tests shouldn't be testing non-public
APIs (good practice) and those assertions were an error originally.

See sebastianbergmann/phpunit#3338 for
the complete list and other details.

When possible (the attributes being checked are public), the change
is simple, just switching to normal assertions.

When the attributes are not public we need to find a workaround
to be able to test the same using public APIs, or use Reflection,
or remove the tests.

For the records, this is the regexp used to find all the cases:

ag '>(assertAttribute|attribute\(|readAttributte|getStaticAttribute| \
    getObjectAttribute)' -G "test.php"
stronk7 added a commit to stronk7/moodle that referenced this issue Oct 9, 2020
With PHPUnit 8 a good number of assertions, all them related with
operations on non-public attributes have been deprecated. And will
be removed with PHPUnit 9.

The main point is that unit tests shouldn't be testing non-public
APIs (good practice) and those assertions were an error originally.

See sebastianbergmann/phpunit#3338 for
the complete list and other details.

When possible (the attributes being checked are public), the change
is simple, just switching to normal assertions.

When the attributes are not public we need to find a workaround
to be able to test the same using public APIs, or use Reflection,
or remove the tests.

For the records, this is the regexp used to find all the cases:

ag '>(assertAttribute|attribute\(|readAttributte|getStaticAttribute| \
    getObjectAttribute)' -G "test.php"
stronk7 added a commit to stronk7/moodle that referenced this issue Oct 13, 2020
With PHPUnit 8 a good number of assertions, all them related with
operations on non-public attributes have been deprecated. And will
be removed with PHPUnit 9.

The main point is that unit tests shouldn't be testing non-public
APIs (good practice) and those assertions were an error originally.

See sebastianbergmann/phpunit#3338 for
the complete list and other details.

When possible (the attributes being checked are public), the change
is simple, just switching to normal assertions.

When the attributes are not public we need to find a workaround
to be able to test the same using public APIs, or use Reflection,
or remove the tests.

For the records, this is the regexp used to find all the cases:

ag '>(assertAttribute|attribute\(|readAttributte|getStaticAttribute| \
    getObjectAttribute)' -G "test.php"
stronk7 added a commit to stronk7/moodle that referenced this issue Oct 13, 2020
With PHPUnit 8 a good number of assertions, all them related with
operations on non-public attributes have been deprecated. And will
be removed with PHPUnit 9.

The main point is that unit tests shouldn't be testing non-public
APIs (good practice) and those assertions were an error originally.

See sebastianbergmann/phpunit#3338 for
the complete list and other details.

When possible (the attributes being checked are public), the change
is simple, just switching to normal assertions.

When the attributes are not public we need to find a workaround
to be able to test the same using public APIs, or use Reflection,
or remove the tests.

For the records, this is the regexp used to find all the cases:

ag '>(assertAttribute|attribute\(|readAttributte|getStaticAttribute| \
    getObjectAttribute)' -G "test.php"
@AlexMalikov94
Copy link

@AlexMalikov94 AlexMalikov94 commented Oct 16, 2020

@sebastianbergmann What alternative using readAttribute(). If it deprecated almost for a secure reason what method I just need for use?

@sebastianbergmann
Copy link
Owner Author

@sebastianbergmann sebastianbergmann commented Oct 16, 2020

@AlexMalikov94 There is no replacement. The correct course of action is to refactor your code to not require dirty tricks like this.

@AlexMalikov94
Copy link

@AlexMalikov94 AlexMalikov94 commented Oct 16, 2020

@sebastianbergmann Yes you are right is dirty tricks but in the past developers used it just I think you have an alternative I see it is not. I just use another function more flexibly. I will contribute your code in the future.

stronk7 added a commit to stronk7/moodle that referenced this issue Oct 16, 2020
With PHPUnit 8 a good number of assertions, all them related with
operations on non-public attributes have been deprecated. And will
be removed with PHPUnit 9.

The main point is that unit tests shouldn't be testing non-public
APIs (good practice) and those assertions were an error originally.

See sebastianbergmann/phpunit#3338 for
the complete list and other details.

When possible (the attributes being checked are public), the change
is simple, just switching to normal assertions.

When the attributes are not public we need to find a workaround
to be able to test the same using public APIs, or use Reflection,
or remove the tests.

For the records, this is the regexp used to find all the cases:

ag '>(assertAttribute|attribute\(|readAttributte|getStaticAttribute| \
    getObjectAttribute)' -G "test.php"
stronk7 added a commit to stronk7/moodle that referenced this issue Oct 16, 2020
With PHPUnit 8 a good number of assertions, all them related with
operations on non-public attributes have been deprecated. And will
be removed with PHPUnit 9.

The main point is that unit tests shouldn't be testing non-public
APIs (good practice) and those assertions were an error originally.

See sebastianbergmann/phpunit#3338 for
the complete list and other details.

When possible (the attributes being checked are public), the change
is simple, just switching to normal assertions.

When the attributes are not public we need to find a workaround
to be able to test the same using public APIs, or use Reflection,
or remove the tests.

For the records, this is the regexp used to find all the cases:

ag '>(assertAttribute|attribute\(|readAttributte|getStaticAttribute| \
    getObjectAttribute)' -G "test.php"
stronk7 added a commit to stronk7/moodle that referenced this issue Oct 21, 2020
With PHPUnit 8 a good number of assertions, all them related with
operations on non-public attributes have been deprecated. And will
be removed with PHPUnit 9.

The main point is that unit tests shouldn't be testing non-public
APIs (good practice) and those assertions were an error originally.

See sebastianbergmann/phpunit#3338 for
the complete list and other details.

When possible (the attributes being checked are public), the change
is simple, just switching to normal assertions.

When the attributes are not public we need to find a workaround
to be able to test the same using public APIs, or use Reflection,
or remove the tests.

For the records, this is the regexp used to find all the cases:

ag '>(assertAttribute|attribute\(|readAttributte|getStaticAttribute| \
    getObjectAttribute)' -G "test.php"
stronk7 added a commit to stronk7/moodle that referenced this issue Oct 21, 2020
With PHPUnit 8 a good number of assertions, all them related with
operations on non-public attributes have been deprecated. And will
be removed with PHPUnit 9.

The main point is that unit tests shouldn't be testing non-public
APIs (good practice) and those assertions were an error originally.

See sebastianbergmann/phpunit#3338 for
the complete list and other details.

When possible (the attributes being checked are public), the change
is simple, just switching to normal assertions.

When the attributes are not public we need to find a workaround
to be able to test the same using public APIs, or use Reflection,
or remove the tests.

For the records, this is the regexp used to find all the cases:

ag '>(assertAttribute|attribute\(|readAttributte|getStaticAttribute| \
    getObjectAttribute)' -G "test.php"
williamdes added a commit to driesvints/php-webdriver that referenced this issue Nov 2, 2020
Removed/Deprecated: sebastianbergmann/phpunit#3338
@svbackend svbackend mentioned this issue Dec 30, 2020
0 of 5 tasks complete
@jensdenies jensdenies mentioned this issue Jan 11, 2021
2 of 6 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants