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

php tests with composer setup #284

Merged
merged 1 commit into from
Jan 18, 2018
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,7 @@ build
__pycache__/
*.py[cod]
*$py.class

tests/phpthemis/vendor
tests/phpthemis/composer.json
tests/phpthemis/composer.phar
63 changes: 63 additions & 0 deletions tests/phpthemis/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Setup

Make install for themis core lib
```
git clone https://github.com/cossacklabs/themis.git
cd themis
sudo make install
```


Make intstall for phpthemis

```
cd tests/phpthemis
sudo make phpthemis_install
```

# Unit tests


You can use shell scripts for convenience
```
composer_setup.sh # to setup PHP Composer

# for PHP 5.6
init_env-php5.6.sh

# for PHP 7.0+
init_env-php7.sh

```

Or proceed manually.

Install Composer locally

```console
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

```

Check you current php version
```console
# to see current state
update-alternatives --display php
# to list all options
update-alternatives --list php
# to set the very one
sudo update-alternatives --set php <path_to_php>
```

Link version specific composer config
```console
ln -s composer-php<version>.json composer.json
```

Update environment
```console
php composer.phar update
```
13 changes: 13 additions & 0 deletions tests/phpthemis/composer-php5.6.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "tests/phpthemis/php-5.6",
"description": "Some stuff for tests",
"autoload": {
"classmap": [
"src/"
]
},
"require": {
"php": "^5.6",
"phpunit/phpunit": "^5"
}
}
13 changes: 13 additions & 0 deletions tests/phpthemis/composer-php7.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "tests/phpthemis/php-7",
"description": "Some stuff for tests",
"autoload": {
"classmap": [
"src/"
]
},
"require": {
"php": "^7",
"phpunit/phpunit": "^6"
}
}
6 changes: 6 additions & 0 deletions tests/phpthemis/composer-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash -e

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
5 changes: 5 additions & 0 deletions tests/phpthemis/init_env-php5.6.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash -e

rm composer.json
ln -s composer-php5.6.json composer.json
php composer.phar update
5 changes: 5 additions & 0 deletions tests/phpthemis/init_env-php7.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash -e

rm composer.json
ln -s composer-php7.json composer.json
php composer.phar update
9 changes: 9 additions & 0 deletions tests/phpthemis/run_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash -e

echo -e "\n >>>> secure cell tests <<<<\\n"
./vendor/phpunit/phpunit/phpunit scell_test.php
echo -e "\n >>>> secure message tests <<<<\n"
./vendor/phpunit/phpunit/phpunit smessage_test.php
echo -e "\n >>>> secure token tests <<<<\n"
# todo:
./vendor/phpunit/phpunit/phpunit ssession_test.php