Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"require-dev": {
"guzzlehttp/guzzle": "^7.0",
"phpunit/phpunit": "*",
"phpunit/phpunit": "^9.5 || ^10.0 || ^11.0 || ^12.0",
"phpstan/phpstan": "^2.1"
},
"suggest": {
Expand All @@ -45,5 +45,9 @@
},
"config": {
"preferred-install": "dist"
},
"scripts": {
"test": "./scripts/phpunit.sh",
"int": "./scripts/integration-test.sh"
}
}
10 changes: 5 additions & 5 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" bootstrap="vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
colors="true"
bootstrap="vendor/autoload.php"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd">
<testsuites>
<testsuite name="Microsoft Dynamics SDK Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<!-- <logging>
<log type="coverage-html" target="coverage/report" charset="UTF-8" yui="true" highlight="true" lowUpperBound="50" highLowerBound="80"/>
</logging> -->
<source>
<include>
<directory suffix=".php">src</directory>
Expand All @@ -16,4 +16,4 @@
<directory suffix=".php">src/Model</directory>
</exclude>
</source>
</phpunit>
</phpunit>
19 changes: 19 additions & 0 deletions phpunit10.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
colors="true"
bootstrap="vendor/autoload.php"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd">
<testsuites>
<testsuite name="Microsoft Dynamics SDK Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
<exclude>
<directory suffix=".php">src/Model</directory>
</exclude>
</source>
</phpunit>
19 changes: 19 additions & 0 deletions phpunit9.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
colors="true"
bootstrap="vendor/autoload.php"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd">
<testsuites>
<testsuite name="Microsoft Dynamics SDK Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
<exclude>
<directory suffix=".php">src/Model</directory>
</exclude>
</coverage>
</phpunit>
70 changes: 70 additions & 0 deletions scripts/integration-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/bin/bash

# Integration test script that runs tests against multiple PHP versions using Laravel Herd

# Array of PHP versions matching our GitHub Actions matrix
PHP_VERSIONS=("7.4" "8.0" "8.1" "8.2" "8.3" "8.4")

# Colors for output
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color

echo "Starting integration tests across PHP versions..."
echo "=============================================="

# Track overall success
OVERALL_SUCCESS=true

# Iterate through each PHP version
for VERSION in "${PHP_VERSIONS[@]}"; do
echo ""
echo -e "${YELLOW}Testing PHP $VERSION${NC}"
echo "------------------------------"

# Switch PHP version using Herd
echo "Switching to PHP $VERSION..."
herd use php@$VERSION

if [ $? -ne 0 ]; then
echo -e "${RED}Failed to switch to PHP $VERSION${NC}"
OVERALL_SUCCESS=false
continue
fi

# Verify PHP version
CURRENT_VERSION=$(php -v | head -n 1)
echo "Current PHP: $CURRENT_VERSION"

# Update composer dependencies for this PHP version
echo "Updating composer dependencies..."
composer update --quiet

if [ $? -ne 0 ]; then
echo -e "${RED}Failed to update dependencies for PHP $VERSION${NC}"
OVERALL_SUCCESS=false
continue
fi

# Run tests
echo "Running tests..."
composer test

if [ $? -eq 0 ]; then
echo -e "${GREEN}✓ Tests passed for PHP $VERSION${NC}"
else
echo -e "${RED}✗ Tests failed for PHP $VERSION${NC}"
OVERALL_SUCCESS=false
fi
done

echo ""
echo "=============================================="
if [ "$OVERALL_SUCCESS" = true ]; then
echo -e "${GREEN}All integration tests passed!${NC}"
exit 0
else
echo -e "${RED}Some integration tests failed!${NC}"
exit 1
fi
19 changes: 19 additions & 0 deletions scripts/phpunit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

# Detect PHPUnit version and use appropriate configuration file

# Get PHPUnit version
PHPUNIT_VERSION=$(vendor/bin/phpunit --version | grep -oP 'PHPUnit \K[0-9]+' || echo "0")

# Choose config file based on version
if [ "$PHPUNIT_VERSION" -ge "10" ]; then
CONFIG_FILE="phpunit10.xml"
elif [ "$PHPUNIT_VERSION" -ge "9" ]; then
CONFIG_FILE="phpunit9.xml"
else
# Fall back to phpunit9.xml for older versions
CONFIG_FILE="phpunit9.xml"
fi

# Run PHPUnit with the appropriate config
vendor/bin/phpunit -c "$CONFIG_FILE" "$@"