Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests #1701

Merged
merged 2 commits into from
Sep 24, 2024
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
2 changes: 1 addition & 1 deletion .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
KERNEL_CLASS='App\Kernel'
APP_SECRET='$ecretf0rt3st'
SYMFONY_DEPRECATIONS_HELPER=999999
DATABASE_URL=mysql://root:@127.0.0.1:3306/f43_test?serverVersion=5.7&charset=utf8mb4
DATABASE_URL=mysql://root:@127.0.0.1:3306/f43_test?serverVersion=9.0.0&charset=utf8mb4
MERCURY_URL=https://mercury.f43.me
PANTHER_APP_ENV=panther
PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: "ubuntu-20.04"
services:
mysql:
image: mysql:5.7
image: mysql:9.0
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: f43_test
Expand All @@ -29,14 +29,15 @@ jobs:
- 5672:5672

env:
DATABASE_URL: mysql://root:@127.0.0.1:3306/f43_test?serverVersion=5.7&charset=utf8mb4
DATABASE_URL: mysql://root:@127.0.0.1:3306/f43_test?serverVersion=9.0.0&charset=utf8mb4

strategy:
matrix:
php:
- "7.4"
- "8.0"
- "8.1"
- "8.2"

steps:
- name: Checkout
Expand Down Expand Up @@ -102,6 +103,7 @@ jobs:
- "7.4"
- "8.0"
- "8.1"
- "8.2"

steps:
- name: Checkout
Expand Down
47 changes: 47 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Contributing

Contributions are welcome, of course.

## Setting up an Environment

You locally need:

- PHP >= 7.4 (with `pdo_mysql` or `pdo_pgsql`) with [Composer](https://getcomposer.org/) installed
- Node.js 20 (use `nvm install`) with Yarn installed
- Docker (to run the database)

Install deps:

```
yarn
composer i
```

Then you can use Docker to launch the database (used for test or dev):

```
docker run -d --name f43me-mysql -e MYSQL_ALLOW_EMPTY_PASSWORD=yes -p 3306:3306 mysql:latest
```

## Running Tests

You can setup the database and the project using:

```
make prepare
```

Once it's ok, launch tests:

```
php bin/simple-phpunit -v
```

## Linting

Linter is used only on PHP files:

```
php bin/php-cs-fixer fix
php bin/phpstan analyse
```
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ You can find some of them in the [converter folder](https://github.com/j0k3r/f43
### Requirements

- PHP >= 7.4 (with `pdo_mysql` or `pdo_pgsql`)
- Node.js 16 (for assets), use `nvm install`
- Node.js 20 (for assets), use `nvm install`
- MySQL >= 5.7 or PostgreSQL
- [RabbitMQ](https://www.rabbitmq.com/), which is optional (see below)
- [Supervisor](http://supervisord.org/) (only if you use RabbitMQ)
Expand Down
3 changes: 0 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,4 @@
<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
</listeners>

<extensions>
</extensions>
</phpunit>
14 changes: 7 additions & 7 deletions tests/Controller/FeedControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,11 @@ public function testFeedNewSubmitEmpty(): void
public function dataNewFeedOk(): array
{
return [[[
'feed[name]' => 'Google News',
'feed[description]' => 'À la une - Google Actualités',
'feed[host]' => 'http://news.google.com',
'feed[name]' => 'j0k3r.n3t',
'feed[description]' => 'j0k3r.n3t',
'feed[host]' => 'https://www.j0k3r.net',
// be sure that link is almost always different
'feed[link]' => 'http://news.google.fr/?output=rss&rand=' . time(),
'feed[link]' => 'https://www.j0k3r.net/feed.xml?rand=' . time(),
'feed[parser]' => 'external',
'feed[formatter]' => 'rss',
'feed[sort_by]' => 'published_at',
Expand Down Expand Up @@ -176,7 +176,7 @@ public function testFeedNewSubmitOk(array $data): void
$location = $client->getResponse()->headers->get('location');

$this->assertSame(302, $client->getResponse()->getStatusCode());
$this->assertStringContainsString('google-news', (string) $location);
$this->assertStringContainsString('j0k3r-n3t', (string) $location);

$crawler = $client->followRedirect();
$this->assertCount(1, $alert = $crawler->filter('p.success')->extract(['_text']));
Expand Down Expand Up @@ -314,13 +314,13 @@ public function testDeleteBadSlug(): void
/**
* @depends testFeedNewSubmitOk
*
* Feed with `google-news` slug will be created
* Feed with `j0k3r-n3t` slug will be created
*/
public function testDeleteOk(): void
{
$client = static::getAuthorizedClient();

$crawler = $client->request('GET', '/feed/google-news/edit');
$crawler = $client->request('GET', '/feed/j0k3r-n3t/edit');

$form = $crawler->filter('form.delete_form button[type=submit]')->form();

Expand Down