From 7e925c92fb8684dee5608b6695c137bdd23e8428 Mon Sep 17 00:00:00 2001 From: Justin Boswell Date: Wed, 5 May 2021 13:37:47 -0700 Subject: [PATCH] Cleanup pass based on prior PRs (#21) * Updates to stub generation * More idiomatic fixes from PHP team * Moved tests from src/tests -> tests, got rid of extension-only tests * fixed up test paths, regenerated arginfo --- composer.json | 7 +------ ext/awscrt.stub.php | 5 ++++- ext/awscrt_arginfo.h | 2 +- src/AWS/CRT/Auth/AwsCredentials.php | 5 ++++- src/AWS/CRT/Auth/CredentialsProvider.php | 5 ++++- src/AWS/CRT/Auth/StaticCredentialsProvider.php | 5 ++++- src/AWS/CRT/CRT.php | 7 +++++-- src/AWS/CRT/HTTP/Headers.php | 5 ++++- src/AWS/CRT/HTTP/Message.php | 6 +++++- src/AWS/CRT/HTTP/Request.php | 7 +++++-- src/AWS/CRT/HTTP/Response.php | 5 ++++- src/AWS/CRT/IO/EventLoopGroup.php | 5 ++++- src/AWS/CRT/IO/InputStream.php | 5 ++++- src/AWS/CRT/Internal/Encoding.php | 5 ++++- src/AWS/CRT/Internal/Extension.php | 5 ++++- src/AWS/CRT/NativeResource.php | 5 ++++- src/AWS/CRT/Options.php | 5 ++++- src/tests/common.inc | 12 ------------ {src/tests => tests}/CredentialsTest.php | 5 ++++- {src/tests => tests}/ErrorTest.php | 5 ++++- {src/tests => tests}/EventLoopGroupTest.php | 5 ++++- {src/tests => tests}/HttpMessageTest.php | 6 ++++-- {src/tests => tests}/StreamTest.php | 5 ++++- tests/aws_crt_error_debug_str.phpt | 14 -------------- tests/aws_crt_error_name.phpt | 14 -------------- tests/aws_crt_error_str.phpt | 14 -------------- tests/aws_crt_event_loop_group.phpt | 16 ---------------- tests/aws_crt_last_error.phpt | 14 -------------- tests/common.inc | 16 ++++++++++++++-- tests/skipif.inc | 3 --- 30 files changed, 99 insertions(+), 119 deletions(-) delete mode 100644 src/tests/common.inc rename {src/tests => tests}/CredentialsTest.php (93%) rename {src/tests => tests}/ErrorTest.php (84%) rename {src/tests => tests}/EventLoopGroupTest.php (83%) rename {src/tests => tests}/HttpMessageTest.php (96%) rename {src/tests => tests}/StreamTest.php (91%) delete mode 100644 tests/aws_crt_error_debug_str.phpt delete mode 100644 tests/aws_crt_error_name.phpt delete mode 100644 tests/aws_crt_error_str.phpt delete mode 100644 tests/aws_crt_event_loop_group.phpt delete mode 100644 tests/aws_crt_last_error.phpt delete mode 100644 tests/skipif.inc diff --git a/composer.json b/composer.json index e887136..0d9b878 100644 --- a/composer.json +++ b/composer.json @@ -27,13 +27,8 @@ "src/" ] }, - "autoload-dev": { - "classmap": [ - "src/tests/" - ] - }, "scripts": { - "test": "@php -d extension=modules/awscrt.so vendor/bin/phpunit src/tests" + "test": "@php -d extension=modules/awscrt.so vendor/bin/phpunit tests" }, "license": "Apache-2.0" } diff --git a/ext/awscrt.stub.php b/ext/awscrt.stub.php index d3a79cf..b795083 100644 --- a/ext/awscrt.stub.php +++ b/ext/awscrt.stub.php @@ -1,6 +1,9 @@ aws_crt_event_loop_group_release($elg); + self::$impl->aws_crt_event_loop_group_release($elg); } /** diff --git a/src/AWS/CRT/HTTP/Headers.php b/src/AWS/CRT/HTTP/Headers.php index 4744182..8d1457c 100644 --- a/src/AWS/CRT/HTTP/Headers.php +++ b/src/AWS/CRT/HTTP/Headers.php @@ -1,5 +1,8 @@ method = $method; $this->path = $path; $this->query = $query; diff --git a/src/AWS/CRT/HTTP/Request.php b/src/AWS/CRT/HTTP/Request.php index 302b7c0..9b4f07c 100644 --- a/src/AWS/CRT/HTTP/Request.php +++ b/src/AWS/CRT/HTTP/Request.php @@ -1,5 +1,8 @@ body_stream = $body_stream; } diff --git a/src/AWS/CRT/HTTP/Response.php b/src/AWS/CRT/HTTP/Response.php index a0f97e4..526edc3 100644 --- a/src/AWS/CRT/HTTP/Response.php +++ b/src/AWS/CRT/HTTP/Response.php @@ -1,5 +1,8 @@ fail("Test left an error on the stack: " . CRT::error_name(CRT::last_error())); - } - } -} diff --git a/src/tests/CredentialsTest.php b/tests/CredentialsTest.php similarity index 93% rename from src/tests/CredentialsTest.php rename to tests/CredentialsTest.php index f645e1b..32a9c42 100644 --- a/src/tests/CredentialsTest.php +++ b/tests/CredentialsTest.php @@ -1,5 +1,8 @@ ---FILE-- - ---EXPECT-- -aws-c-common: AWS_ERROR_SUCCESS, Success. diff --git a/tests/aws_crt_error_name.phpt b/tests/aws_crt_error_name.phpt deleted file mode 100644 index 1d1c779..0000000 --- a/tests/aws_crt_error_name.phpt +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -aws_crt_error_name ---SKIPIF-- - ---FILE-- - ---EXPECT-- -AWS_ERROR_SUCCESS diff --git a/tests/aws_crt_error_str.phpt b/tests/aws_crt_error_str.phpt deleted file mode 100644 index ba9703f..0000000 --- a/tests/aws_crt_error_str.phpt +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -aws_crt_error_str ---SKIPIF-- - ---FILE-- - ---EXPECT-- -Success. diff --git a/tests/aws_crt_event_loop_group.phpt b/tests/aws_crt_event_loop_group.phpt deleted file mode 100644 index a549a23..0000000 --- a/tests/aws_crt_event_loop_group.phpt +++ /dev/null @@ -1,16 +0,0 @@ ---TEST-- -aws_crt_event_loop_group ---SKIPIF-- - ---FILE-- - ---EXPECTREGEX-- -int\(\d+\) diff --git a/tests/aws_crt_last_error.phpt b/tests/aws_crt_last_error.phpt deleted file mode 100644 index 144e073..0000000 --- a/tests/aws_crt_last_error.phpt +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -aws_crt_last_error ---SKIPIF-- - ---FILE-- - ---EXPECT-- -0 diff --git a/tests/common.inc b/tests/common.inc index de45b95..4156715 100644 --- a/tests/common.inc +++ b/tests/common.inc @@ -1,3 +1,15 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ +use AWS\CRT\CRT as CRT; + +abstract class CrtTestCase extends PHPUnit_Framework_TestCase { + // Ensure that after every test there are no errors in the CRT itself + protected function assertPostConditions() { + if (CRT::last_error()) { + $this->fail("Test left an error on the stack: " . CRT::error_name(CRT::last_error())); + } + } +} diff --git a/tests/skipif.inc b/tests/skipif.inc deleted file mode 100644 index f0ac746..0000000 --- a/tests/skipif.inc +++ /dev/null @@ -1,3 +0,0 @@ -