mirror of
https://github.com/awslabs/aws-crt-php.git
synced 2026-08-17 17:47:12 +00:00
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
This commit is contained in:
+1
-6
@@ -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"
|
||||
}
|
||||
|
||||
+4
-1
@@ -1,6 +1,9 @@
|
||||
<?php
|
||||
|
||||
/** @generate-class-entries */
|
||||
/**
|
||||
* @generate-class-entries
|
||||
* @generate-function-entries
|
||||
*/
|
||||
|
||||
function aws_crt_last_error(): int {}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* This is a generated file, edit the .stub.php file instead.
|
||||
* Stub hash: bd274f6b280b27aa5fb7d3be2ce85ad065936943 */
|
||||
* Stub hash: 5101b351fa7644a60919f40e09b7877a31a6d3bd */
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_aws_crt_last_error, 0, 0, IS_LONG, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0.
|
||||
*/
|
||||
namespace AWS\CRT\Auth;
|
||||
|
||||
use AWS\CRT\NativeResource as NativeResource;
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0.
|
||||
*/
|
||||
namespace AWS\CRT\Auth;
|
||||
|
||||
use AWS\CRT\NativeResource as NativeResource;
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0.
|
||||
*/
|
||||
namespace AWS\CRT\Auth;
|
||||
|
||||
/**
|
||||
|
||||
+5
-2
@@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0.
|
||||
*/
|
||||
namespace AWS\CRT;
|
||||
|
||||
use AWS\CRT\Internal\Extension;
|
||||
@@ -102,7 +105,7 @@ final class CRT {
|
||||
* @param object $elg Pointer to the event loop group to release
|
||||
*/
|
||||
function event_loop_group_release($elg) {
|
||||
return self::$impl->aws_crt_event_loop_group_release($elg);
|
||||
self::$impl->aws_crt_event_loop_group_release($elg);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0.
|
||||
*/
|
||||
namespace AWS\CRT\HTTP;
|
||||
|
||||
use AWS\CRT\Internal\Encoding;
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0.
|
||||
*/
|
||||
namespace AWS\CRT\HTTP;
|
||||
|
||||
use AWS\CRT\NativeResource;
|
||||
@@ -12,6 +15,7 @@ abstract class Message extends NativeResource {
|
||||
private $headers;
|
||||
|
||||
public function __construct($method, $path, $query = [], $headers = []) {
|
||||
parent::__construct();
|
||||
$this->method = $method;
|
||||
$this->path = $path;
|
||||
$this->query = $query;
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0.
|
||||
*/
|
||||
namespace AWS\CRT\HTTP;
|
||||
|
||||
use AWS\CRT\IO\InputStream;
|
||||
@@ -10,7 +13,7 @@ class Request extends Message {
|
||||
public function __construct($method, $path, $query = [], $headers = [], $body_stream = null) {
|
||||
parent::__construct($method, $path, $query, $headers);
|
||||
if (!is_null($body_stream) && !($body_stream instanceof InputStream)) {
|
||||
throw \InvalidArgumentException('body_stream must be an ' . InputStream::class);
|
||||
throw InvalidArgumentException('body_stream must be an instance of ' . InputStream::class);
|
||||
}
|
||||
$this->body_stream = $body_stream;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0.
|
||||
*/
|
||||
namespace AWS\CRT\HTTP;
|
||||
|
||||
class Response extends Message {
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0.
|
||||
*/
|
||||
namespace AWS\CRT\IO;
|
||||
|
||||
use AWS\CRT\NativeResource as NativeResource;
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0.
|
||||
*/
|
||||
namespace AWS\CRT\IO;
|
||||
|
||||
use AWS\CRT\NativeResource as NativeResource;
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0.
|
||||
*/
|
||||
namespace AWS\CRT\Internal;
|
||||
|
||||
final class Encoding {
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0.
|
||||
*/
|
||||
namespace AWS\CRT\Internal;
|
||||
|
||||
use \RuntimeException;
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0.
|
||||
*/
|
||||
namespace AWS\CRT;
|
||||
|
||||
use AWS\CRT\CRT as CRT;
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0.
|
||||
*/
|
||||
namespace AWS\CRT;
|
||||
|
||||
final class Options {
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0.
|
||||
*/
|
||||
use AWS\CRT\Auth\AwsCredentials as AwsCredentials;
|
||||
use AWS\CRT\Auth\StaticCredentialsProvider as StaticCredentialsProvider;
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0.
|
||||
*/
|
||||
use AWS\CRT\CRT;
|
||||
|
||||
final class ErrorTest extends PHPUnit_Framework_TestCase {
|
||||
@@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0.
|
||||
*/
|
||||
use AWS\CRT\IO\EventLoopGroup as EventLoopGroup;
|
||||
|
||||
require_once('common.inc');
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
use AWS\CRT\HTTP\Message;
|
||||
/**
|
||||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0.
|
||||
*/
|
||||
use AWS\CRT\HTTP\Headers;
|
||||
use AWS\CRT\HTTP\Request;
|
||||
use AWS\CRT\HTTP\Response;
|
||||
@@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0.
|
||||
*/
|
||||
use AWS\CRT\IO\InputStream as InputStream;
|
||||
|
||||
require_once('common.inc');
|
||||
@@ -1,14 +0,0 @@
|
||||
--TEST--
|
||||
aws_crt_error_debug_str
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(dirname(__FILE__) . '/skipif.inc');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__) . '/common.inc');
|
||||
|
||||
echo aws_crt_error_debug_str(0);
|
||||
?>
|
||||
--EXPECT--
|
||||
aws-c-common: AWS_ERROR_SUCCESS, Success.
|
||||
@@ -1,14 +0,0 @@
|
||||
--TEST--
|
||||
aws_crt_error_name
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(dirname(__FILE__) . '/skipif.inc');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__) . '/common.inc');
|
||||
|
||||
echo aws_crt_error_name(0);
|
||||
?>
|
||||
--EXPECT--
|
||||
AWS_ERROR_SUCCESS
|
||||
@@ -1,14 +0,0 @@
|
||||
--TEST--
|
||||
aws_crt_error_str
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(dirname(__FILE__) . '/skipif.inc');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__) . '/common.inc');
|
||||
|
||||
echo aws_crt_error_str(0);
|
||||
?>
|
||||
--EXPECT--
|
||||
Success.
|
||||
@@ -1,16 +0,0 @@
|
||||
--TEST--
|
||||
aws_crt_event_loop_group
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(dirname(__FILE__) . '/skipif.inc');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__) . '/common.inc');
|
||||
|
||||
$elg = aws_crt_event_loop_group_new(1);
|
||||
var_dump($elg);
|
||||
aws_crt_event_loop_group_release($elg);
|
||||
?>
|
||||
--EXPECTREGEX--
|
||||
int\(\d+\)
|
||||
@@ -1,14 +0,0 @@
|
||||
--TEST--
|
||||
aws_crt_last_error
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(dirname(__FILE__) . '/skipif.inc');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__) . '/common.inc');
|
||||
|
||||
echo aws_crt_last_error();
|
||||
?>
|
||||
--EXPECT--
|
||||
0
|
||||
+14
-2
@@ -1,3 +1,15 @@
|
||||
<?php
|
||||
// Common setup for tests:
|
||||
?>
|
||||
/**
|
||||
* 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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
<?php
|
||||
extension_loaded('awscrt') or die('awscrt is not available in this build');
|
||||
?>
|
||||
Reference in New Issue
Block a user