Skip to content

Commit 8acbfff

Browse files
author
Екатерина Чмиль
committed
init hexlet-phpunit project
0 parents  commit 8acbfff

File tree

14 files changed

+3812
-0
lines changed

14 files changed

+3812
-0
lines changed

.codeclimate

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
engines:
2+
duplication:
3+
enabled: true
4+
config:
5+
languages:
6+
- php
7+
fixme:
8+
enabled: true
9+
phpmd:
10+
enabled: true

.github/workflows/workflow.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Name of workflow
2+
name: PHP CI
3+
4+
# Trigger the workflow on push or pull request
5+
on:
6+
- push
7+
- pull_request
8+
9+
jobs:
10+
build:
11+
12+
# The type of machine to run the job on
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
# Check-out repository under GitHub workspace
17+
# https://github.com/actions/checkout
18+
- uses: actions/checkout@v3
19+
# Step's name
20+
- name: Setup PHP
21+
# Action gives to setup the PHP environment to test application
22+
# https://github.com/shivammathur/setup-php
23+
uses: shivammathur/setup-php@v2
24+
with:
25+
# Specify the PHP version
26+
php-version: '8.2'
27+
- name: Install
28+
# Install project
29+
run: make install
30+
- name: Run linter
31+
# Run Linter
32+
run: make lint
33+
# Publish code coverage on Code Climate
34+
# https://github.com/paambaati/codeclimate-action
35+
# NOTE: uncomment for using workflow
36+
# - name: Run test & publish code coverage
37+
# uses: paambaati/codeclimate-action@v5
38+
# # Add Code Climate secret key
39+
# env:
40+
# CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
41+
# with:
42+
# coverageCommand: make test-coverage
43+
# coverageLocations: build/logs/clover.xml:clover
44+
# debug: true

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/vendor/
2+
logs
3+
*.swo
4+
*.swp
5+
*.cache
6+
build

.tool-versions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
php 8.2.10

Makefile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
install:
2+
composer install
3+
4+
console:
5+
composer exec --verbose psysh
6+
7+
lint:
8+
composer exec --verbose phpcs -- --standard=PSR12 src tests
9+
composer exec --verbose phpstan
10+
11+
lint-fix:
12+
composer exec --verbose phpcbf -- --standard=PSR12 src tests
13+
14+
test:
15+
composer exec --verbose phpunit tests
16+
17+
test-coverage:
18+
XDEBUG_MODE=coverage composer exec --verbose phpunit tests -- --coverage-clover build/logs/clover.xml
19+
20+
test-coverage-text:
21+
XDEBUG_MODE=coverage composer exec --verbose phpunit tests -- --coverage-text

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# php-package
2+
3+
[![Github Actions Status](https://github.com/hexlet-boilerplates/php-package/workflows/PHP%20CI/badge.svg)](https://github.com/hexlet-boilerplates/php-package/actions)
4+
[![Code Climate](https://codeclimate.com/github/hexlet-boilerplates/php-package/badges/gpa.svg)](https://codeclimate.com/github/hexlet-boilerplates/php-package)
5+
[![Issue Count](https://codeclimate.com/github/hexlet-boilerplates/php-package/badges/issue_count.svg)](https://codeclimate.com/github/hexlet-boilerplates/php-package/issues)
6+
[![Test Coverage](https://codeclimate.com/github/hexlet-boilerplates/php-package/badges/coverage.svg)](https://codeclimate.com/github/hexlet-boilerplates/php-package/coverage)
7+
8+
## Prerequisites
9+
10+
* Linux, Macos, WSL
11+
* PHP >=8.2
12+
* Xdebug
13+
* Make
14+
* Git
15+
16+
## Addons
17+
18+
Use <http://psysh.org/>
19+
20+
## Setup
21+
22+
```bash
23+
git clone https://github.com/hexlet-boilerplates/php-package.git
24+
cd php-package
25+
make install
26+
```
27+
28+
## Run tests
29+
30+
```sh
31+
make test
32+
```
33+
34+
## Test Coverage
35+
36+
* see `phpunit.xml`
37+
* See [codeclimate documentation](https://docs.codeclimate.com/docs/configuring-test-coverage)
38+
* add `CC_TEST_REPORTER_ID` to workflow as SECRETS ENV VARIABLE (for safety)
39+
40+
[![Hexlet Ltd. logo](https://raw.githubusercontent.com/Hexlet/assets/master/images/hexlet_logo128.png)](https://hexlet.io/?utm_source=github&utm_medium=link&utm_campaign=php-package)
41+
42+
This repository is created and maintained by the team and the community of Hexlet, an educational project. [Read more about Hexlet](https://hexlet.io/?utm_source=github&utm_medium=link&utm_campaign=php-package).
43+
44+
45+
See most active contributors on [hexlet-friends](https://friends.hexlet.io/).

bin/php-package

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env php
2+
3+
<?php
4+
5+
$autoloadPath1 = __DIR__ . '/../../../autoload.php';
6+
$autoloadPath2 = __DIR__ . '/../vendor/autoload.php';
7+
if (file_exists($autoloadPath1)) {
8+
require_once $autoloadPath1;
9+
} else {
10+
require_once $autoloadPath2;
11+
}
12+
13+
echo 'what is your name?: ';
14+
$name = trim(fgets(STDIN));
15+
16+
$user = new Php\Package\User($name);
17+
18+
var_dump($user);
19+

composer.json

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"name": "hexlet/php-package",
3+
"bin": ["bin/php-package"],
4+
"type": "library",
5+
"authors": [
6+
{
7+
"name": "Kirill Mokevnin",
8+
"email": "[email protected]"
9+
}
10+
],
11+
"description": "hexlet php-package",
12+
"license": "MIT",
13+
"scripts": {
14+
"test": "phpunit tests"
15+
},
16+
"autoload": {
17+
"psr-4": {
18+
"Php\\Package\\": "src"
19+
}
20+
},
21+
"autoload-dev": {
22+
"psr-4": {
23+
"Php\\Package\\Tests\\": "tests"
24+
}
25+
},
26+
"require": {
27+
"illuminate/collections": "^11.0",
28+
"nesbot/carbon": "^3.0",
29+
"symfony/string": "^7.0",
30+
"phpstan/phpstan": "^1.10"
31+
},
32+
"require-dev": {
33+
"psy/psysh": "@stable",
34+
"phpstan/phpstan-phpunit": "^1.3",
35+
"phpstan/extension-installer": "^1.3",
36+
"symfony/var-dumper": "^7.0",
37+
"phpunit/phpunit": "^11.0",
38+
"squizlabs/php_codesniffer": "*"
39+
},
40+
"config": {
41+
"allow-plugins": {
42+
"phpstan/extension-installer": true
43+
}
44+
}
45+
}

0 commit comments

Comments
 (0)