Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
Also add contributing file to remember how to test the project 🧌
  • Loading branch information
j0k3r committed Sep 24, 2024
1 parent abb790e commit d3b49bf
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 12 deletions.
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
4 changes: 2 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,7 +29,7 @@ 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:
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>
10 changes: 5 additions & 5 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

0 comments on commit d3b49bf

Please sign in to comment.