Skip to content

Commit def3b93

Browse files
author
Julien Neuhart
committed
adding unit test + improving code
1 parent be59a5f commit def3b93

20 files changed

+249
-27
lines changed

docker-compose.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ services:
3838
- mysql_data:/var/lib/mysql
3939
- ./services/mysql/utf8mb4.cnf:/etc/mysql/conf.d/utf8mb4.cnf:ro
4040

41+
mysql_tests:
42+
image: mysql:5.7
43+
environment:
44+
MYSQL_ROOT_PASSWORD: "admin"
45+
MYSQL_DATABASE: "tests"
46+
MYSQL_USER: "foo"
47+
MYSQL_PASSWORD: "bar"
48+
volumes:
49+
- ./services/mysql/utf8mb4.cnf:/etc/mysql/conf.d/utf8mb4.cnf:ro
50+
4151
phpmyadmin:
4252
image: phpmyadmin/phpmyadmin:4.7
4353
labels:

sources/app/assets/vue/api/post.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import axios from "axios";
22

33
export default {
44
create(message) {
5-
return axios.post("/api/post/create", {
5+
return axios.post("/api/posts", {
66
message: message
77
});
88
},
9-
posts() {
9+
findAll() {
1010
return axios.get("/api/posts");
1111
}
1212
};

sources/app/assets/vue/components/ErrorMessage.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default {
1212
name: "ErrorMessage",
1313
props: {
1414
error: {
15-
type: Object,
15+
type: Error,
1616
required: true
1717
}
1818
},

sources/app/assets/vue/store/post.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ export default {
7474
return null;
7575
}
7676
},
77-
async posts({ commit }) {
77+
async findAll({ commit }) {
7878
commit(FETCHING_POSTS);
7979
try {
80-
let response = await PostAPI.posts();
80+
let response = await PostAPI.findAll();
8181
commit(FETCHING_POSTS_SUCCESS, response.data);
8282
return response.data;
8383
} catch (error) {

sources/app/assets/vue/views/Posts.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export default {
9999
}
100100
},
101101
created() {
102-
this.$store.dispatch("post/posts");
102+
this.$store.dispatch("post/findAll");
103103
},
104104
methods: {
105105
async createPost() {

sources/app/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"squizlabs/php_codesniffer": "^3.4",
4141
"symfony/debug-pack": "*",
4242
"symfony/maker-bundle": "^1.0",
43+
"symfony/phpunit-bridge": "^4.3",
4344
"symfony/profiler-pack": "*",
4445
"symfony/test-pack": "*",
4546
"symfony/web-server-bundle": "4.3.*",
@@ -73,7 +74,7 @@
7374
"scripts": {
7475
"csfix": "phpcbf --ignore=src/Migrations/**,src/Kernel.php",
7576
"cscheck": "phpcs --ignore=src/Migrations/**,src/Kernel.php",
76-
"phpstan": "phpstan analyse src/ tests/ -c phpstan.neon --level=7 --no-progress -vvv --memory-limit=1024M",
77+
"phpstan": "phpstan analyse src/ -c phpstan.neon --level=7 --no-progress -vvv --memory-limit=1024M",
7778
"auto-scripts": {
7879
"cache:clear": "symfony-cmd",
7980
"assets:install %PUBLIC_DIR%": "symfony-cmd"

sources/app/composer.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sources/app/config/packages/security.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ security:
22
# https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
33
encoders:
44
App\Entity\User:
5-
algorithm: bcrypt
5+
algorithm: auto
66
providers:
77
in_memory: { memory: ~ }
88
pdo:

sources/app/config/services.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ services:
2626

2727
# add more service definitions when explicit configuration is needed
2828
# please note that last definitions always *replace* previous ones
29+
App\Exception\HTTPExceptionListener:
30+
tags:
31+
- { name: kernel.event_listener, event: kernel.exception }
32+
2933
app.security.hash.password.listener:
3034
class: App\Security\HashPasswordListener
3135
tags:

sources/app/phpcs.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
<!-- Directories to be checked -->
1212
<file>src</file>
13-
<!-- <file>tests</file> -->
13+
<file>tests</file>
1414

1515
<exclude-pattern>tests/dependencies/*</exclude-pattern>
1616

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy