Skip to content

Commit a3e3f93

Browse files
committed
ISSUE-337: ci
1 parent ff1e96c commit a3e3f93

File tree

6 files changed

+66
-180
lines changed

6 files changed

+66
-180
lines changed

.github/workflows/ci.yml

+8-17
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
DB_DATABASE: phplist
99
DB_USERNAME: root
1010
DB_PASSWORD: phplist
11-
BROADCAST_DRIVER: log
11+
BROADCAST_DRIVER: log
1212
services:
1313
mysql:
1414
image: mysql:5.7
@@ -22,17 +22,21 @@ jobs:
2222
strategy:
2323
fail-fast: false
2424
matrix:
25-
php-versions: ['7.2', '7.3', '7.4', '8.0']
26-
# dependencies: ['latest', 'oldest']
25+
php-versions: ['8.1']
2726
steps:
2827
- name: Checkout
2928
uses: actions/checkout@v2
3029
- name: Setup PHP, with composer and extensions
31-
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
30+
uses: shivammathur/setup-php@v2
3231
with:
3332
php-version: ${{ matrix.php-versions }}
3433
extensions: mbstring, dom, fileinfo, mysql
3534
coverage: xdebug #optional
35+
- name: Install Symfony CLI
36+
run: |
37+
curl -sS https://get.symfony.com/cli/installer | bash
38+
mv $HOME/.symfony*/bin/symfony /usr/local/bin/symfony
39+
symfony version
3640
- name: Start mysql service
3741
run: sudo /etc/init.d/mysql start
3842
- name: Verify MySQL connection on host
@@ -44,36 +48,23 @@ jobs:
4448
uses: actions/cache@v2
4549
with:
4650
path: ${{ steps.composer-cache.outputs.dir }}
47-
# Use composer.json for key, if composer.lock is not committed.
48-
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
4951
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
5052
restore-keys: ${{ runner.os }}-composer-
5153
- name: Install the latest dependencies
5254
run: composer install
53-
continue-on-error: ${{matrix.php-versions == '8.0' }} # [temp-php8]
54-
# - name: Install lowest dependencies from
55-
# run: composer update --with-dependencies --prefer-stable --prefer-dist --prefer-lowest
56-
# if: ${{ matrix.dependencies }} == "oldest"
5755
- name: Set up database schema
5856
run: mysql --host 127.0.0.1 --port ${{ job.services.mysql.ports['3306'] }} -u${{ env.DB_USERNAME }} -p${{ env.DB_PASSWORD }} ${{ env.DB_DATABASE }} < vendor/phplist/core/resources/Database/Schema.sql
59-
continue-on-error: ${{matrix.php-versions == '8.0' }} # [temp-php8]
6057
- name: Validating composer.json
6158
run: composer validate --no-check-all --no-check-lock --strict;
62-
continue-on-error: ${{matrix.php-versions == '8.0' }} # [temp-php8]
6359
- name: Linting all php files
6460
run: find src/ tests/ public/ -name ''*.php'' -print0 | xargs -0 -n 1 -P 4 php -l; php -l;
6561
- name: Running integration tests with phpunit
6662
run: vendor/bin/phpunit tests/Integration/;
67-
continue-on-error: ${{matrix.php-versions == '8.0' }} # [temp-php8]
6863
- name: Running the system tests
6964
run: vendor/bin/phpunit tests/System/;
70-
continue-on-error: ${{matrix.php-versions == '8.0' }} # [temp-php8]
7165
- name: Running static analysis
7266
run: vendor/bin/phpstan analyse -l 5 src/ tests/;
73-
continue-on-error: ${{matrix.php-versions == '8.0' }} # [temp-php8]
7467
- name: Running PHPMD
7568
run: vendor/bin/phpmd src/ text vendor/phplist/core/config/PHPMD/rules.xml;
76-
continue-on-error: ${{matrix.php-versions == '8.0' }} # [temp-php8]
7769
- name: Running PHP_CodeSniffer
7870
run: vendor/bin/phpcs --standard=vendor/phplist/core/config/PhpCodeSniffer/ src/ tests/;
79-
continue-on-error: ${{matrix.php-versions == '8.0' }} # [temp-php8]

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@
1313
/public/
1414
/var/
1515
/vendor/
16+
.phpunit.result.cache

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ This project adheres to [Semantic Versioning](https://semver.org/).
1616

1717
### Fixed
1818

19+
## 5.0.0-alpha1
20+
21+
### Changed
22+
- updated to php8.1
23+
1924
## 4.0.0-alpha2
2025

2126
### Added

composer.json

+5-14
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@
3333
"phplist/core": "dev-ISSUE-337"
3434
},
3535
"require-dev": {
36-
"phpunit/phpunit": "^9.5.2",
37-
"phpunit/phpunit-mock-objects": "^6.1.2",
36+
"phpunit/phpunit": "^9.5",
3837
"guzzlehttp/guzzle": "^7.2.0",
3938
"squizlabs/php_codesniffer": "^3.5.8",
40-
"phpstan/phpstan": " ^0.12.57",
39+
"phpstan/phpstan": "^1.10",
4140
"nette/caching": "^3.1.0",
4241
"nikic/php-parser": "^v4.10.4",
43-
"phpmd/phpmd": "^2.9.1"
42+
"phpmd/phpmd": "^2.9.1",
43+
"symfony/process": "^6.4"
4444
},
4545
"autoload": {
4646
"psr-4": {
@@ -52,15 +52,6 @@
5252
"PhpList\\WebFrontend\\Tests\\": "tests/"
5353
}
5454
},
55-
"repositories": [
56-
{
57-
"type": "path",
58-
"url": "../core",
59-
"options": {
60-
"symlink": true
61-
}
62-
}
63-
],
6455
"scripts": {
6556
"list-modules": [
6657
"PhpList\\Core\\Composer\\ScriptHandler::listModules"
@@ -87,7 +78,7 @@
8778
},
8879
"extra": {
8980
"branch-alias": {
90-
"dev-ISSUE-337": "v5.0.x-dev"
81+
"dev-ISSUE-337": "5.0.x-dev"
9182
},
9283
"symfony-app-dir": "bin",
9384
"symfony-bin-dir": "bin",
+29-107
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
namespace PhpList\WebFrontend\Tests\Integration\Composer;
@@ -12,148 +13,69 @@
1213
*/
1314
class ScriptsTest extends TestCase
1415
{
15-
/**
16-
* @test
17-
*/
18-
public function publicDirectoryHasBeenCreated()
19-
{
20-
static::assertDirectoryExists($this->getAbsolutePublicDirectoryPath());
21-
}
22-
23-
/**
24-
* @return string
25-
*/
26-
private function getAbsolutePublicDirectoryPath(): string
27-
{
28-
return dirname(__DIR__, 3) . '/public/';
29-
}
30-
31-
/**
32-
* @return string[][]
33-
*/
34-
public function publicDirectoryFilesDataProvider(): array
35-
{
36-
return [
37-
'production entry point' => ['app.php'],
38-
'development entry point' => ['app_dev.php'],
39-
'testing entry point' => ['app_test.php'],
40-
'.htaccess' => ['.htaccess'],
41-
];
42-
}
43-
44-
/**
45-
* @test
46-
* @param string $fileName
47-
* @dataProvider publicDirectoryFilesDataProvider
48-
*/
49-
public function publicDirectoryFilesExist(string $fileName)
50-
{
51-
static::assertFileExists($this->getAbsolutePublicDirectoryPath() . $fileName);
52-
}
53-
54-
/**
55-
* @test
56-
*/
57-
public function binariesDirectoryHasBeenCreated()
16+
private function getBundleConfigurationFilePath(): string
5817
{
59-
static::assertDirectoryExists($this->getAbsoluteBinariesDirectoryPath());
18+
return dirname(__DIR__, 3) . '/config/bundles.yml';
6019
}
6120

62-
/**
63-
* @return string
64-
*/
65-
private function getAbsoluteBinariesDirectoryPath(): string
21+
public function testBundleConfigurationFileExists(): void
6622
{
67-
return dirname(__DIR__, 3) . '/bin/';
23+
self::assertFileExists($this->getBundleConfigurationFilePath());
6824
}
6925

70-
/**
71-
* @return string[][]
72-
*/
73-
public function binariesDataProvider(): array
26+
public function bundleClassNameDataProvider(): array
7427
{
7528
return [
76-
'Symfony console' => ['console'],
29+
'Symfony framework bundle' => ['Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle'],
30+
'Doctrine bundle' => ['Doctrine\\Bundle\\DoctrineBundle\\DoctrineBundle'],
31+
'empty start page bundle' => ['PhpList\\Core\\EmptyStartPageBundle\\EmptyStartPageBundle'],
7732
];
7833
}
7934

8035
/**
81-
* @test
82-
* @param string $fileName
83-
* @dataProvider binariesDataProvider
36+
* @dataProvider bundleClassNameDataProvider
8437
*/
85-
public function binariesExist(string $fileName)
38+
public function testBundleConfigurationFileContainsModuleBundles(string $bundleClassName): void
8639
{
87-
static::assertFileExists($this->getAbsoluteBinariesDirectoryPath() . $fileName);
40+
$fileContents = file_get_contents($this->getBundleConfigurationFilePath());
41+
self::assertStringContainsString($bundleClassName, $fileContents);
8842
}
8943

90-
/**
91-
* @return string
92-
*/
93-
private function getBundleConfigurationFilePath(): string
44+
private function getModuleRoutesConfigurationFilePath(): string
9445
{
95-
return dirname(__DIR__, 3) . '/config/bundles.yml';
46+
return dirname(__DIR__, 3) . '/config/routing_modules.yml';
9647
}
9748

98-
/**
99-
* @test
100-
*/
101-
public function bundleConfigurationFileExists()
49+
public function testModuleRoutesConfigurationFileExists(): void
10250
{
103-
static::assertFileExists($this->getBundleConfigurationFilePath());
51+
self::assertFileExists($this->getModuleRoutesConfigurationFilePath());
10452
}
10553

106-
/**
107-
* @return string[][]
108-
*/
109-
public function bundleClassNameDataProvider(): array
54+
public function moduleRoutingDataProvider(): array
11055
{
11156
return [
112-
'framework bundle' => ['Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle'],
57+
'route name' => ['phplist/core.homepage'],
58+
'resource' => ["resource: '@EmptyStartPageBundle/Controller/'"],
59+
'type' => ['type: attribute'],
11360
];
11461
}
11562

11663
/**
117-
* @test
118-
* @param string $bundleClassName
119-
* @dataProvider bundleClassNameDataProvider
120-
*/
121-
public function bundleConfigurationFileContainsModuleBundles(string $bundleClassName)
122-
{
123-
$fileContents = file_get_contents($this->getBundleConfigurationFilePath());
124-
125-
static::assertContains($bundleClassName, $fileContents);
126-
}
127-
128-
/**
129-
* @return string
130-
*/
131-
private function getModuleRoutesConfigurationFilePath(): string
132-
{
133-
return dirname(__DIR__, 3) . '/config/routing_modules.yml';
134-
}
135-
136-
/**
137-
* @test
64+
* @dataProvider moduleRoutingDataProvider
13865
*/
139-
public function moduleRoutesConfigurationFileExists()
66+
public function testModuleRoutesConfigurationFileContainsModuleRoutes(string $routeSearchString): void
14067
{
141-
static::assertFileExists($this->getModuleRoutesConfigurationFilePath());
68+
$fileContents = file_get_contents($this->getModuleRoutesConfigurationFilePath());
69+
self::assertStringContainsString($routeSearchString, $fileContents);
14270
}
14371

144-
/**
145-
* @test
146-
*/
147-
public function parametersConfigurationFileExists()
72+
public function testParametersConfigurationFileExists(): void
14873
{
149-
static::assertFileExists(dirname(__DIR__, 3) . '/config/parameters.yml');
74+
self::assertFileExists(dirname(__DIR__, 3) . '/config/parameters.yml');
15075
}
15176

152-
/**
153-
* @test
154-
*/
155-
public function modulesConfigurationFileExists()
77+
public function testModulesConfigurationFileExists(): void
15678
{
157-
static::assertFileExists(dirname(__DIR__, 3) . '/config/config_modules.yml');
79+
self::assertFileExists(dirname(__DIR__, 3) . '/config/config_modules.yml');
15880
}
15981
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
namespace PhpList\WebFrontend\Tests\System\ApplicationBundle;
@@ -16,57 +17,32 @@ class PhpListApplicationBundleTest extends TestCase
1617
{
1718
use SymfonyServerTrait;
1819

19-
/**
20-
* @var Client
21-
*/
22-
private $httpClient = null;
20+
private ?Client $httpClient = null;
2321

24-
protected function setUp()
22+
protected function setUp(): void
2523
{
24+
parent::setUp();
2625
$this->httpClient = new Client(['http_errors' => false]);
2726
}
2827

29-
protected function tearDown()
28+
protected function tearDown(): void
3029
{
3130
$this->stopSymfonyServer();
31+
$this->httpClient = null;
32+
parent::tearDown();
3233
}
3334

34-
/**
35-
* @return string[][]
36-
*/
37-
public function environmentDataProvider(): array
38-
{
39-
return [
40-
'test' => ['test'],
41-
'dev' => ['dev'],
42-
];
43-
}
44-
45-
/**
46-
* @test
47-
* @param string $environment
48-
* @dataProvider environmentDataProvider
49-
*/
50-
public function homepageReturnsSuccess(string $environment)
35+
public function testHomepageReturnsSuccess(): void
5136
{
52-
$this->startSymfonyServer($environment);
53-
54-
$response = $this->httpClient->get('/', ['base_uri' => $this->getBaseUrl()]);
55-
56-
static::assertSame(200, $response->getStatusCode());
57-
}
58-
59-
/**
60-
* @test
61-
* @param string $environment
62-
* @dataProvider environmentDataProvider
63-
*/
64-
public function homepageReturnsContent(string $environment)
65-
{
66-
$this->startSymfonyServer($environment);
67-
68-
$response = $this->httpClient->get('/', ['base_uri' => $this->getBaseUrl()]);
69-
70-
static::assertNotEmpty($response->getBody()->getContents());
37+
$this->startSymfonyServer();
38+
$response = $this->httpClient->get('/api/v2', [
39+
'base_uri' => $this->getBaseUrl(),
40+
]);
41+
42+
self::assertSame(200, $response->getStatusCode());
43+
self::assertStringContainsString(
44+
'This page has been intentionally left empty.',
45+
$response->getBody()->getContents()
46+
);
7147
}
7248
}

0 commit comments

Comments
 (0)