Updated and simplified PHP testing structure (#8558)
* Simplified PHP testing setup.
- Consolidated on a single autoloader, created by composer.
- Consolidated on a single phpunit invocation strategy: we run
phpunit on a directory, which will run all tests matching *Test.php
in that directory.
- We now rely on autoloading to import all test protos. require_once()
calls for test protos are removed.
- For now the valgrind tests are removed. A follow-up PR will re-enable
them in a more robust way.
* More improvements to PHP testing.
1. Replace custom PHPUnit-selection logic in test.sh with generic
composer version selection.
2. Optimized both test proto generation and the custom extension
build to avoid unnecessary work when the files are already up
to date.
* Added assertions to verify that the C test doesn't use PHP sources.
* Updated tests.sh for the new PHP testing commands.
* Removed obsolete rules from tests.sh.
* Fixed generate_test_protos.sh for when tmp does not exist.
Also removed undefined_test.php and fixed Makefile.am.
* Added php8.0_all again which is still used.
* Added missing file to Makefile.am.
* Re-added php_all_32 rule which is also still used.
* Updated testing commands for macOS and download composer.
* Use /usr/local/bin on mac instead of /usr/bin, since the latter is not writable.
diff --git a/php/tests/GeneratedClassTest.php b/php/tests/GeneratedClassTest.php
index f2a9fb0..8759391 100644
--- a/php/tests/GeneratedClassTest.php
+++ b/php/tests/GeneratedClassTest.php
@@ -1,7 +1,5 @@
<?php
-require_once('generated/NoNamespaceEnum.php');
-require_once('generated/NoNamespaceMessage.php');
require_once('test_base.php');
require_once('test_util.php');
@@ -759,10 +757,10 @@
public function testMessageWithoutNamespace()
{
$m = new TestMessage();
- $n = new NoNameSpaceMessage();
+ $n = new NoNamespaceMessage();
$m->setOptionalNoNamespaceMessage($n);
$repeatedNoNamespaceMessage = $m->getRepeatedNoNamespaceMessage();
- $repeatedNoNamespaceMessage[] = new NoNameSpaceMessage();
+ $repeatedNoNamespaceMessage[] = new NoNamespaceMessage();
$m->setRepeatedNoNamespaceMessage($repeatedNoNamespaceMessage);
// test nested messages
@@ -775,9 +773,9 @@
public function testEnumWithoutNamespace()
{
$m = new TestMessage();
- $m->setOptionalNoNamespaceEnum(NoNameSpaceEnum::VALUE_A);
+ $m->setOptionalNoNamespaceEnum(NoNamespaceEnum::VALUE_A);
$repeatedNoNamespaceEnum = $m->getRepeatedNoNamespaceEnum();
- $repeatedNoNamespaceEnum[] = NoNameSpaceEnum::VALUE_A;
+ $repeatedNoNamespaceEnum[] = NoNamespaceEnum::VALUE_A;
$m->setRepeatedNoNamespaceEnum($repeatedNoNamespaceEnum);
$this->assertTrue(true);
}