Skip to content

Commit 161d74a

Browse files
Add unit tests to run
1 parent bf79bd1 commit 161d74a

File tree

5 files changed

+72
-12
lines changed

5 files changed

+72
-12
lines changed

.github/workflows/magento-2.3.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,15 @@ jobs:
101101
michielgerritsen/magento-project-community-edition:${{ matrix.cfg.PHP_VERSION }}-magento${{ matrix.cfg.MAGENTO_VERSION }}-sample-data
102102

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

106106
- name: Copy the example test module
107107
run: |
108108
docker exec magento-project-community-edition mkdir -p /data/extensions/MichielGerritsen-ExampleTest/Test/Integration/
109+
docker exec magento-project-community-edition mkdir -p /data/extensions/MichielGerritsen-ExampleTest/Test/Unit/
109110
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/
111+
docker cp Test/ExampleIntegrationTest.php magento-project-community-edition:/data/extensions/MichielGerritsen-ExampleTest/Test/Integration/
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/integration/ && ../../../vendor/bin/phpunit /data/vendor/michielgerritsen/exampletest/Test/Integration/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: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,13 +267,17 @@ jobs:
267267
michielgerritsen/magento-project-community-edition:${{ matrix.cfg.PHP_VERSION }}-magento${{ matrix.cfg.MAGENTO_VERSION }}-sample-data
268268

269269
- name: Create the dummy test directory
270-
run: docker exec magento-project-community-edition mkdir -p /data/app/code/MichielGerritsen/Magento2ExtensionIntegrationTest/Test/Integration
270+
run: |
271+
docker exec magento-project-community-edition mkdir -p /data/app/code/MichielGerritsen/Magento2ExtensionTest/Test/Integration
272+
docker exec magento-project-community-edition mkdir -p /data/app/code/MichielGerritsen/Magento2ExtensionTest/Test/Unit
271273
272274
- name: Copy the example test module
273275
run: |
274276
docker exec magento-project-community-edition mkdir -p /data/extensions/MichielGerritsen-ExampleTest/Test/Integration/
277+
docker exec magento-project-community-edition mkdir -p /data/extensions/MichielGerritsen-ExampleTest/Test/unit/
275278
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/
279+
docker cp Test/ExampleIntegrationTest.php magento-project-community-edition:/data/extensions/MichielGerritsen-ExampleTest/Test/Integration/
280+
docker cp Test/ExampleUnitTest.php magento-project-community-edition:/data/extensions/MichielGerritsen-ExampleTest/Test/Unit/
277281
278282
- name: Install the example test module
279283
run: docker exec magento-project-community-edition composer require michielgerritsen/exampletest:@dev
@@ -284,8 +288,11 @@ jobs:
284288
- name: Run setup:di:compile
285289
run: docker exec magento-project-community-edition ./retry "php bin/magento setup:di:compile"
286290

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"
291+
- name: Run the example integration test
292+
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"
293+
294+
- name: Run the example unit test
295+
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"
289296

290297
# Step 3: Upload the images to Docker Hub.
291298
- 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: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
use Magento\Framework\App\Config\ScopeConfigInterface;
22+
use Magento\TestFramework\ObjectManager;
23+
24+
class ExampleIntegrationTest extends \PHPUnit\Framework\TestCase
25+
{
26+
/**
27+
* The only goal of this test is to check if test can be run successful.
28+
*/
29+
public function testSuccess()
30+
{
31+
$this->assertTrue(true);
32+
}
33+
34+
/**
35+
* @magentoConfigFixture current_store general/store_information/name Magento 2 test store
36+
*/
37+
public function testCanUseConfigFixture(): void
38+
{
39+
$result = ObjectManager::getInstance()->get(ScopeConfigInterface::class)->getValue(
40+
'general/store_information/name',
41+
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
42+
);
43+
44+
$this->assertEquals('Magento 2 test store', $result);
45+
}
46+
}

0 commit comments

Comments
 (0)