Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit dacf6d8

Browse filesBrowse files
committed
wip
1 parent 350cfd5 commit dacf6d8
Copy full SHA for dacf6d8

File tree

Expand file treeCollapse file tree

2 files changed

+248
-3
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+248
-3
lines changed

‎.github/workflows/unit-tests.yml

Copy file name to clipboardExpand all lines: .github/workflows/unit-tests.yml
+223-3Lines changed: 223 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ permissions:
1717

1818
jobs:
1919

20-
tests:
20+
linux-tests:
21+
runs-on: ubuntu-20.04
22+
2123
name: Unit Tests
2224

2325
env:
@@ -38,8 +40,6 @@ jobs:
3840
#mode: experimental
3941
fail-fast: false
4042

41-
runs-on: ubuntu-20.04
42-
4343
steps:
4444
- name: Checkout
4545
uses: actions/checkout@v4
@@ -235,3 +235,223 @@ jobs:
235235
cd ..
236236
237237
./build/php/bin/php ./phpunit --colors=always src/Symfony/Component/Process
238+
239+
windows_tests:
240+
241+
runs-on: windows-2022
242+
243+
name: PHP ${{ matrix.php }} - Windows
244+
245+
env:
246+
extensions: amqp,apcu,igbinary,intl,mbstring,memcached,redis-5.3.4
247+
248+
strategy:
249+
matrix:
250+
include:
251+
- php: '7.2'
252+
- php: '7.4'
253+
- php: '8.2'
254+
mode: high-deps
255+
- php: '8.2'
256+
mode: low-deps
257+
- php: '8.3'
258+
- php: '8.4'
259+
extensions: amqp,apcu,igbinary,intl,mbstring,memcached,redis
260+
#mode: experimental
261+
fail-fast: false
262+
263+
steps:
264+
- name: Checkout
265+
uses: actions/checkout@v4
266+
with:
267+
fetch-depth: 2
268+
269+
- name: Setup PHP
270+
uses: shivammathur/setup-php@v2
271+
with:
272+
coverage: "none"
273+
ini-values: date.timezone=UTC,memory_limit=-1,default_socket_timeout=10,session.gc_probability=0,apc.enable_cli=1,zend.assertions=1
274+
php-version: "${{ matrix.php }}"
275+
extensions: "${{ matrix.extensions || env.extensions }}"
276+
tools: flex
277+
278+
- name: Configure environment
279+
run: |
280+
git config --global user.email ""
281+
git config --global user.name "Symfony"
282+
git config --global init.defaultBranch main
283+
git config --global advice.detachedHead false
284+
285+
COMPOSER_HOME="$(composer config home)"
286+
([ -d "$COMPOSER_HOME" ] || mkdir "$COMPOSER_HOME") && cp .github/composer-config.json "$COMPOSER_HOME/config.json"
287+
288+
echo COLUMNS=120 >> $GITHUB_ENV
289+
echo PHPUNIT="$(pwd)/phpunit --exclude-group tty,benchmark,intl-data,integration" >> $GITHUB_ENV
290+
echo COMPOSER_UP='composer update --no-progress --ansi'$([[ "${{ matrix.mode }}" != low-deps ]] && echo ' --ignore-platform-req=php+') >> $GITHUB_ENV
291+
echo SYMFONY_DEPRECATIONS_HELPER="baselineFile=$(pwd)/.github/deprecations-baseline.json" >> $GITHUB_ENV
292+
293+
SYMFONY_VERSIONS=$(git ls-remote -q --heads | cut -f2 | grep -o '/[1-9][0-9]*\.[0-9].*' | sort -V)
294+
SYMFONY_VERSION=$(grep ' VERSION = ' src/Symfony/Component/HttpKernel/Kernel.php | cut -d "'" -f2 | cut -d '.' -f 1-2)
295+
SYMFONY_FEATURE_BRANCH=$(curl -s https://raw.githubusercontent.com/symfony/recipes/flex/main/index.json | jq -r '.versions."dev-name"')
296+
297+
# Install the phpunit-bridge from a PR if required
298+
#
299+
# To run a PR with a patched phpunit-bridge, first submit the patch for the
300+
# phpunit-bridge as a separate PR against the next feature-branch then
301+
# uncomment and update the following line with that PR number
302+
#SYMFONY_PHPUNIT_BRIDGE_PR=32886
303+
304+
if [[ $SYMFONY_PHPUNIT_BRIDGE_PR ]]; then
305+
git fetch --depth=2 origin refs/pull/$SYMFONY_PHPUNIT_BRIDGE_PR/head
306+
git rm -rq src/Symfony/Bridge/PhpUnit
307+
git checkout -q FETCH_HEAD -- src/Symfony/Bridge/PhpUnit
308+
SYMFONY_PHPUNIT_BRIDGE_REF=$(curl -s https://api.github.com/repos/symfony/symfony/pulls/$SYMFONY_PHPUNIT_BRIDGE_PR | jq -r .base.ref)
309+
sed -i 's/"symfony\/phpunit-bridge": ".*"/"symfony\/phpunit-bridge": "'$SYMFONY_PHPUNIT_BRIDGE_REF'.x@dev"/' composer.json
310+
rm -rf .phpunit
311+
fi
312+
313+
# Create local composer packages for each patched components and reference them in composer.json files when cross-testing components
314+
if [[ ! "${{ matrix.mode }}" = *-deps ]]; then
315+
php .github/build-packages.php HEAD^ $SYMFONY_VERSION src/Symfony/Bridge/PhpUnit
316+
else
317+
echo SYMFONY_DEPRECATIONS_HELPER=weak >> $GITHUB_ENV
318+
cp composer.json composer.json.orig
319+
echo -e '{\n"require":{'"$(grep phpunit-bridge composer.json)"'"php":"*"},"minimum-stability":"dev"}' > composer.json
320+
php .github/build-packages.php HEAD^ $SYMFONY_VERSION $(find src/Symfony -mindepth 2 -type f -name composer.json -printf '%h\n')
321+
mv composer.json composer.json.phpunit
322+
mv composer.json.orig composer.json
323+
fi
324+
if [[ $SYMFONY_PHPUNIT_BRIDGE_PR ]]; then
325+
git rm -fq -- src/Symfony/Bridge/PhpUnit/composer.json
326+
git diff --staged -- src/Symfony/Bridge/PhpUnit/ | git apply -R --index
327+
fi
328+
329+
# For the highest branch, in high-deps mode, the version before it is checked out and tested with the locally patched components
330+
if [[ "${{ matrix.mode }}" = high-deps && $SYMFONY_VERSION = $(echo "$SYMFONY_VERSIONS" | tail -n 1 | sed s/.//) ]]; then
331+
echo FLIP='^' >> $GITHUB_ENV
332+
SYMFONY_VERSION=$(echo "$SYMFONY_VERSIONS" | grep -FB1 /$SYMFONY_VERSION | head -n 1 | sed s/.//)
333+
git fetch --depth=2 origin $SYMFONY_VERSION
334+
git checkout -m FETCH_HEAD
335+
echo COMPONENTS=$(find src/Symfony -mindepth 2 -type f -name phpunit.xml.dist -printf '%h ') >> $GITHUB_ENV
336+
fi
337+
338+
# Skip the phpunit-bridge on bugfix-branches when not in *-deps mode
339+
if [[ ! "${{ matrix.mode }}" = *-deps && $SYMFONY_VERSION != $SYMFONY_FEATURE_BRANCH ]]; then
340+
echo COMPONENTS=$(find src/Symfony -mindepth 2 -type f -name phpunit.xml.dist -not -wholename '*/Bridge/PhpUnit/*' | xargs -I{} dirname {}) >> $GITHUB_ENV
341+
else
342+
echo COMPONENTS=$(find src/Symfony -mindepth 2 -type f -name phpunit.xml.dist | xargs -I{} dirname {}) >> $GITHUB_ENV
343+
fi
344+
345+
# Legacy tests are skipped when deps=high and when the current branch version has not the same major version number as the next one
346+
[[ "${{ matrix.mode }}" = high-deps && $SYMFONY_VERSION = *.4 ]] && echo LEGACY=,legacy >> $GITHUB_ENV || true
347+
348+
echo SYMFONY_VERSION=$SYMFONY_VERSION >> $GITHUB_ENV
349+
echo COMPOSER_ROOT_VERSION=$SYMFONY_VERSION.x-dev >> $GITHUB_ENV
350+
echo SYMFONY_REQUIRE=">=$([ '${{ matrix.mode }}' = low-deps ] && echo 4.4 || echo $SYMFONY_VERSION)" >> $GITHUB_ENV
351+
[[ "${{ matrix.mode }}" = *-deps ]] && mv composer.json.phpunit composer.json || true
352+
353+
- name: Install dependencies
354+
run: |
355+
echo "::group::composer update"
356+
$COMPOSER_UP
357+
echo "::endgroup::"
358+
359+
echo "::group::install phpunit"
360+
./phpunit install
361+
echo "::endgroup::"
362+
363+
- name: Patch return types
364+
if: "matrix.php == '8.1' && ! matrix.mode"
365+
run: |
366+
sed -i 's/"\*\*\/Tests\/"//' composer.json
367+
git add .
368+
composer install -q --optimize-autoloader
369+
SYMFONY_PATCH_TYPE_DECLARATIONS='force=1&php=7.2' php .github/patch-types.php
370+
SYMFONY_PATCH_TYPE_DECLARATIONS='force=1&php=7.2' php .github/patch-types.php # ensure the script is idempotent
371+
git diff --exit-code
372+
echo PHPUNIT="$PHPUNIT,legacy" >> $GITHUB_ENV
373+
374+
- name: Run tests
375+
run: |
376+
_run_tests() {
377+
local ok=0
378+
local title="$1$FLIP"
379+
local start=$(date -u +%s)
380+
OUTPUT=$(bash -xc "$2" 2>&1) || ok=$?
381+
local end=$(date -u +%s)
382+
383+
if [[ $ok -ne 0 ]]; then
384+
printf "\n%-70s%10s\n" $title $(($end-$start))s
385+
echo "$OUTPUT"
386+
echo "Job exited with: $ok"
387+
echo -e "\n::error::KO $title\\n"
388+
else
389+
printf "::group::%-68s%10s\n" $title $(($end-$start))s
390+
echo "$OUTPUT"
391+
echo -e "\n\\e[32mOK\\e[0m $title\\n\\n::endgroup::"
392+
fi
393+
394+
[[ "${{ matrix.mode }}" = experimental ]] || (exit $ok)
395+
}
396+
export -f _run_tests
397+
398+
if [[ ! "${{ matrix.mode }}" = *-deps ]]; then
399+
echo "$COMPONENTS" | xargs -n1 | parallel -j +3 "_run_tests {} '$PHPUNIT {}'"
400+
401+
exit 0
402+
fi
403+
404+
if [[ "${{ matrix.mode }}" = low-deps ]]; then
405+
echo "$COMPONENTS" | xargs -n1 | parallel -j +3 "_run_tests {} 'cd {} && $COMPOSER_UP --prefer-lowest --prefer-stable && $PHPUNIT'"
406+
407+
exit 0
408+
fi
409+
410+
(cd src/Symfony/Component/HttpFoundation; cp composer.json composer.bak; composer require --dev --no-update mongodb/mongodb)
411+
(cd src/Symfony/Component/Lock; cp composer.json composer.bak; composer require --dev --no-update mongodb/mongodb)
412+
413+
# matrix.mode = high-deps
414+
echo "$COMPONENTS" | xargs -n1 | parallel -j +3 "_run_tests {} 'cd {} && $COMPOSER_UP && $PHPUNIT$LEGACY'" || X=1
415+
416+
# get a list of the patched components (relies on .github/build-packages.php being called in the previous step)
417+
(cd src/Symfony/Component/HttpFoundation; mv composer.bak composer.json)
418+
(cd src/Symfony/Component/Lock; mv composer.bak composer.json)
419+
PATCHED_COMPONENTS=$(git diff --name-only src/ | grep composer.json || true)
420+
421+
# for 5.4 LTS, checkout and test previous major with the patched components (only for patched components)
422+
if [[ $PATCHED_COMPONENTS && $SYMFONY_VERSION = 5.4 ]]; then
423+
export FLIP='^'
424+
SYMFONY_VERSION=$(echo $SYMFONY_VERSION | awk '{print $1 - 1}')
425+
echo -e "\\n\\e[33;1mChecking out Symfony $SYMFONY_VERSION and running tests with patched components as deps\\e[0m"
426+
export COMPOSER_ROOT_VERSION=$SYMFONY_VERSION.x-dev
427+
export SYMFONY_REQUIRE=">=$SYMFONY_VERSION"
428+
git fetch --depth=2 origin $SYMFONY_VERSION
429+
git checkout -m FETCH_HEAD
430+
PATCHED_COMPONENTS=$(echo "$PATCHED_COMPONENTS" | xargs dirname | xargs -n1 -I{} bash -c "[ -e '{}/phpunit.xml.dist' ] && echo '{}'" | sort || true)
431+
(cd src/Symfony/Component/HttpFoundation; composer require --dev --no-update mongodb/mongodb)
432+
(cd src/Symfony/Component/Lock; composer require --dev --no-update mongodb/mongodb)
433+
if [[ $PATCHED_COMPONENTS ]]; then
434+
echo "::group::install phpunit"
435+
./phpunit install
436+
echo "::endgroup::"
437+
echo "$PATCHED_COMPONENTS" | parallel -j +3 "_run_tests {} 'cd {} && rm composer.lock vendor/ -Rf && $COMPOSER_UP && $PHPUNIT$LEGACY'" || X=1
438+
fi
439+
fi
440+
441+
[[ ! $X ]] || (exit 1)
442+
443+
- name: Run TTY tests
444+
if: "! matrix.mode"
445+
run: |
446+
script -e -c './phpunit --group tty' /dev/null
447+
448+
- name: Run tests with SIGCHLD enabled PHP
449+
if: "matrix.php == '7.2' && ! matrix.mode"
450+
run: |
451+
mkdir build
452+
cd build
453+
wget -q https://github.com/symfony/binary-utils/releases/download/v0.1/php-7.2.5-pcntl-sigchild.tar.bz2
454+
tar -xjf php-7.2.5-pcntl-sigchild.tar.bz2
455+
cd ..
456+
457+
./build/php/bin/php ./phpunit --colors=always src/Symfony/Component/Process

‎src/Symfony/Component/Mailer/Tests/Transport/Smtp/EsmtpTransportTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Mailer/Tests/Transport/Smtp/EsmtpTransportTest.php
+25Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
namespace Symfony\Component\Mailer\Tests\Transport\Smtp;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Mailer\Exception\TransportException;
1516
use Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport;
17+
use Symfony\Component\Mime\Email;
1618

1719
class EsmtpTransportTest extends TestCase
1820
{
@@ -40,4 +42,27 @@ public function testToString()
4042
$t = new EsmtpTransport('example.com', 466, true);
4143
$this->assertEquals('smtps://example.com:466', (string) $t);
4244
}
45+
46+
public function testTypeErrorInMailer()
47+
{
48+
$transport = new EsmtpTransport(
49+
'smtp.mailtrap.io',
50+
587,
51+
null
52+
);
53+
$transport->setUsername('foo');
54+
$transport->setPassword('bar');
55+
56+
$message = new Email();
57+
$message->from('sender@example.org');
58+
$message->addTo('recipient@example.org');
59+
$message->text('.');
60+
61+
try {
62+
$transport->send($message);
63+
$this->fail('Symfony\Component\Mailer\Exception\TransportException to be thrown');
64+
} catch (TransportException $e) {
65+
$this->assertStringStartsWith('Failed to authenticate on SMTP server with username "foo" using the following authenticators: "CRAM-MD5", "LOGIN", "PLAIN".', $e->getMessage());
66+
}
67+
}
4368
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.