Skip to content

Commit cb6ada4

Browse files
Add unit tests to run
1 parent bf79bd1 commit cb6ada4

File tree

5 files changed

+60
-18
lines changed

5 files changed

+60
-18
lines changed

.github/workflows/magento-2.3.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,16 @@ jobs:
100100
docker run --detach --name magento-project-community-edition
101101
michielgerritsen/magento-project-community-edition:${{ matrix.cfg.PHP_VERSION }}-magento${{ matrix.cfg.MAGENTO_VERSION }}-sample-data
102102

103-
- name: Create the dummy test directory
104-
run: docker exec magento-project-community-edition mkdir -p /data/app/code/MichielGerritsen/Magento2ExtensionIntegrationTest/Test/Integration
105-
106103
- name: Copy the example test module
107104
run: |
108-
docker exec magento-project-community-edition mkdir -p /data/extensions/MichielGerritsen-ExampleTest/Test/Integration/
105+
docker exec magento-project-community-edition mkdir -vp /data/extensions/MichielGerritsen-ExampleTest/Test/Integration/
106+
docker exec magento-project-community-edition mkdir -vp /data/extensions/MichielGerritsen-ExampleTest/Test/Unit/
107+
echo "Copying Test/composer.json"
109108
docker cp Test/composer.json magento-project-community-edition:/data/extensions/MichielGerritsen-ExampleTest/
110-
docker cp Test/ExampleTest.php magento-project-community-edition:/data/extensions/MichielGerritsen-ExampleTest/Test/Integration/
109+
echo "Copying Test/ExampleIntegrationTest.php"
110+
docker cp Test/ExampleIntegrationTest.php magento-project-community-edition:/data/extensions/MichielGerritsen-ExampleTest/Test/Integration/
111+
echo "Copying Test/ExampleUnitTest.php"
112+
docker cp Test/ExampleUnitTest.php magento-project-community-edition:/data/extensions/MichielGerritsen-ExampleTest/Test/Unit/
111113
112114
- name: Install the example test module
113115
run: docker exec magento-project-community-edition composer require michielgerritsen/exampletest:@dev
@@ -118,8 +120,11 @@ jobs:
118120
- name: Run setup:di:compile
119121
run: docker exec magento-project-community-edition ./retry "php bin/magento setup:di:compile"
120122

121-
- name: Run the example test
122-
run: docker exec magento-project-community-edition bash -c "cd /data/dev/tests/integration/ && ../../../vendor/bin/phpunit /data/vendor/michielgerritsen/exampletest/Test/Integration/ExampleTest.php"
123+
- name: Run the example integration test
124+
run: docker exec magento-project-community-edition bash -c "cd /data/dev/tests/integration/ && ../../../vendor/bin/phpunit /data/vendor/michielgerritsen/exampletest/Test/Integration/ExampleIntegrationTest.php"
125+
126+
- name: Run the example unit test
127+
run: docker exec magento-project-community-edition bash -c "cd /data/dev/tests/unit/ && ../../../vendor/bin/phpunit /data/vendor/michielgerritsen/exampletest/Test/Unit/ExampleUnitTest.php"
123128

124129
# Step 3: Upload the images to Docker Hub.
125130
- name: Docker hub login

.github/workflows/magento-2.4.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -266,14 +266,16 @@ jobs:
266266
docker run --detach --name magento-project-community-edition
267267
michielgerritsen/magento-project-community-edition:${{ matrix.cfg.PHP_VERSION }}-magento${{ matrix.cfg.MAGENTO_VERSION }}-sample-data
268268

269-
- name: Create the dummy test directory
270-
run: docker exec magento-project-community-edition mkdir -p /data/app/code/MichielGerritsen/Magento2ExtensionIntegrationTest/Test/Integration
271-
272269
- name: Copy the example test module
273270
run: |
274-
docker exec magento-project-community-edition mkdir -p /data/extensions/MichielGerritsen-ExampleTest/Test/Integration/
271+
docker exec magento-project-community-edition mkdir -vp /data/extensions/MichielGerritsen-ExampleTest/Test/Integration/
272+
docker exec magento-project-community-edition mkdir -vp /data/extensions/MichielGerritsen-ExampleTest/Test/Unit/
273+
echo "Copying Test/composer.json"
275274
docker cp Test/composer.json magento-project-community-edition:/data/extensions/MichielGerritsen-ExampleTest/
276-
docker cp Test/ExampleTest.php magento-project-community-edition:/data/extensions/MichielGerritsen-ExampleTest/Test/Integration/
275+
echo "Copying Test/ExampleIntegrationTest.php"
276+
docker cp Test/ExampleIntegrationTest.php magento-project-community-edition:/data/extensions/MichielGerritsen-ExampleTest/Test/Integration/
277+
echo "Copying Test/ExampleUnitTest.php"
278+
docker cp Test/ExampleUnitTest.php magento-project-community-edition:/data/extensions/MichielGerritsen-ExampleTest/Test/Unit/
277279
278280
- name: Install the example test module
279281
run: docker exec magento-project-community-edition composer require michielgerritsen/exampletest:@dev
@@ -284,8 +286,11 @@ jobs:
284286
- name: Run setup:di:compile
285287
run: docker exec magento-project-community-edition ./retry "php bin/magento setup:di:compile"
286288

287-
- name: Run the example test
288-
run: docker exec magento-project-community-edition bash -c "cd /data/dev/tests/integration/ && ../../../vendor/bin/phpunit /data/vendor/michielgerritsen/exampletest/Test/Integration/ExampleTest.php"
289+
- name: Run the example integration test
290+
run: docker exec magento-project-community-edition bash -c "cd /data/dev/tests/integration/ && ../../../vendor/bin/phpunit /data/vendor/michielgerritsen/exampletest/Test/Integration/ExampleIntegrationTest.php"
291+
292+
- name: Run the example unit test
293+
run: docker exec magento-project-community-edition bash -c "cd /data/dev/tests/unit/ && ../../../vendor/bin/phpunit /data/vendor/michielgerritsen/exampletest/Test/Unit/ExampleUnitTest.php"
289294

290295
# Step 3: Upload the images to Docker Hub.
291296
- name: Docker hub login

.github/workflows/magento-with-replacements.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,15 @@ jobs:
3939
michielgerritsen/magento-project-community-edition:${{ matrix.cfg.PHP_VERSION }}-magento${{ matrix.cfg.MAGENTO_VERSION }}-with-replacements
4040

4141
- name: Create the dummy test directory
42-
run: docker exec magento-project-community-edition mkdir -p /data/app/code/MichielGerritsen/Magento2ExtensionIntegrationTest/Test/Integration
42+
run: docker exec magento-project-community-edition mkdir -p /data/app/code/MichielGerritsen/Magento2ExtensionTest/Test/Integration
4343

4444
- name: Copy the example test module
4545
run: |
4646
docker exec magento-project-community-edition mkdir -p /data/extensions/MichielGerritsen-ExampleTest/Test/Integration/
47+
docker exec magento-project-community-edition mkdir -p /data/extensions/MichielGerritsen-ExampleTest/Test/Unit/
4748
docker cp Test/composer.json magento-project-community-edition:/data/extensions/MichielGerritsen-ExampleTest/
48-
docker cp Test/ExampleTest.php magento-project-community-edition:/data/extensions/MichielGerritsen-ExampleTest/Test/Integration/
49+
docker cp Test/ExampleIntegrationTest.php magento-project-community-edition:/data/extensions/MichielGerritsen-ExampleTest/Test/Integration/
50+
docker cp Test/ExampleUnitTest.php magento-project-community-edition:/data/extensions/MichielGerritsen-ExampleTest/Test/Unit/
4951
5052
- name: Install the example test module
5153
run: docker exec magento-project-community-edition composer require michielgerritsen/exampletest:@dev
@@ -57,7 +59,7 @@ jobs:
5759
run: docker exec magento-project-community-edition ./retry "php bin/magento setup:di:compile"
5860

5961
- name: Run the example test
60-
run: docker exec magento-project-community-edition bash -c "cd /data/dev/tests/integration/ && ../../../vendor/bin/phpunit /data/vendor/michielgerritsen/exampletest/Test/Integration/ExampleTest.php"
62+
run: docker exec magento-project-community-edition bash -c "cd /data/dev/tests/integration/ && ../../../vendor/bin/phpunit /data/vendor/michielgerritsen/exampletest/Test/Integration/ExampleIntegrationTest.php"
6163

6264
# Step 3: Upload the images to Docker Hub.
6365
- name: Docker hub login

Test/ExampleTest.php renamed to Test/ExampleIntegrationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
use Magento\Framework\App\Config\ScopeConfigInterface;
2222
use Magento\TestFramework\ObjectManager;
2323

24-
class ExampleTest extends \PHPUnit\Framework\TestCase
24+
class ExampleIntegrationTest extends \PHPUnit\Framework\TestCase
2525
{
2626
/**
2727
* The only goal of this test is to check if test can be run successful.

Test/ExampleUnitTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
/**
3+
* ______ __ __
4+
* / ____/___ ____ / /__________ / /
5+
* / / / __ \/ __ \/ __/ ___/ __ \/ /
6+
* / /___/ /_/ / / / / /_/ / / /_/ / /
7+
* \______________/_/\__/_/ \____/_/
8+
* / | / / /_
9+
* / /| | / / __/
10+
* / ___ |/ / /_
11+
* /_/ _|||_/\__/ __ __
12+
* / __ \___ / /__ / /____
13+
* / / / / _ \/ / _ \/ __/ _ \
14+
* / /_/ / __/ / __/ /_/ __/
15+
* /_____/\___/_/\___/\__/\___/
16+
*
17+
*/
18+
19+
namespace MichielGerritsen\ExampleTest\Test\Unit;
20+
21+
class ExampleUnitTest extends \PHPUnit\Framework\TestCase
22+
{
23+
/**
24+
* The only goal of this test is to check if test can be run successful.
25+
*/
26+
public function testSuccess()
27+
{
28+
$this->assertTrue(true);
29+
}
30+
}

0 commit comments

Comments
 (0)