From afa20ee9bceb5f1d420ad8707156d5b6b5c2e5fe Mon Sep 17 00:00:00 2001 From: Dave Liddament Date: Mon, 12 Aug 2024 19:51:07 +0100 Subject: [PATCH] FIX example code for TestTag on a class --- .../testTag/testTagClassOnConstructor.php | 31 +++++++++++++ ...agClassOnConstructorIgnoredInTestClass.php | 21 +++++++++ examples/testTag/testTagClassOnMethod.php | 32 ++++++++++++++ ...testTagClassOnMethodIgnoredInTestClass.php | 25 +++++++++++ .../testTag/testTagClassOnStaticMethod.php | 34 +++++++++++++++ ...gClassOnStaticMethodIgnoredInTestClass.php | 22 ++++++++++ examples/testTag/testTagOnClass.php | 43 ------------------- .../testTagOnClassIgnoredInTestClass.php | 40 ----------------- 8 files changed, 165 insertions(+), 83 deletions(-) create mode 100644 examples/testTag/testTagClassOnConstructor.php create mode 100644 examples/testTag/testTagClassOnConstructorIgnoredInTestClass.php create mode 100644 examples/testTag/testTagClassOnMethod.php create mode 100644 examples/testTag/testTagClassOnMethodIgnoredInTestClass.php create mode 100644 examples/testTag/testTagClassOnStaticMethod.php create mode 100644 examples/testTag/testTagClassOnStaticMethodIgnoredInTestClass.php delete mode 100644 examples/testTag/testTagOnClass.php delete mode 100644 examples/testTag/testTagOnClassIgnoredInTestClass.php diff --git a/examples/testTag/testTagClassOnConstructor.php b/examples/testTag/testTagClassOnConstructor.php new file mode 100644 index 0000000..fe76ec3 --- /dev/null +++ b/examples/testTag/testTagClassOnConstructor.php @@ -0,0 +1,31 @@ +updateName(); // OK - whole class is marked with TestTag, so OK to call methods within it. + } +} + +class Updater +{ + public function updater(Person $person): void + { + $person->updateName(); // ERROR + } +} + +$person = new Person(); +$person->updateName(); // ERROR + diff --git a/examples/testTag/testTagClassOnMethodIgnoredInTestClass.php b/examples/testTag/testTagClassOnMethodIgnoredInTestClass.php new file mode 100644 index 0000000..9e067f8 --- /dev/null +++ b/examples/testTag/testTagClassOnMethodIgnoredInTestClass.php @@ -0,0 +1,25 @@ +updateName(); // OK - Called from Test class + } +} + + diff --git a/examples/testTag/testTagClassOnStaticMethod.php b/examples/testTag/testTagClassOnStaticMethod.php new file mode 100644 index 0000000..6d8d397 --- /dev/null +++ b/examples/testTag/testTagClassOnStaticMethod.php @@ -0,0 +1,34 @@ + 0) { - $this->aMethod($number - 1); // OK, class can interact with itself - } - } -} - -class AnotherClass -{ - public function newInstance(): Person - { - return new Person(); // ERROR - } - - public function buildPerson(): Person - { - return Person::create(); // ERROR - } - - public function aMethod(Person $person): void - { - $person->aMethod(1); // ERROR - } -} diff --git a/examples/testTag/testTagOnClassIgnoredInTestClass.php b/examples/testTag/testTagOnClassIgnoredInTestClass.php deleted file mode 100644 index 6f689e2..0000000 --- a/examples/testTag/testTagOnClassIgnoredInTestClass.php +++ /dev/null @@ -1,40 +0,0 @@ -aMethod(); // OK, call from test class - } -}