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

Unit tests #9

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
.idea/

# Ignore development environment artefacts.
*~
.vagrant
ansible/*.retry

# Ignore Composer artefacts.
composer.lock
vendor/
17 changes: 17 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
# Configure a single virtual machine.
config.vm.box = "debian/contrib-stretch64"
config.vm.hostname = "b2db"

# Use Ansible for provisining the virtual machine. Use local provisioning in
# order not to polute the user's host system.
config.vm.provision "ansible_local" do |ansible|
ansible.playbook = "ansible/provision.yml"
ansible.install_mode = "pip"
ansible.version = "2.7.5"
ansible.compatibility_mode = "2.0"
end
end
72 changes: 72 additions & 0 deletions ansible/provision.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---

- hosts: all
become: yes
tasks:

# Package installation.
- name: Install packages for Ansible use
apt:
name:
- python-mysqldb

- name: Install database servers
apt:
name:
- mariadb-server
state: present

- name: Install PHP and B2DB requirements
apt:
name:
# Core for library itself.
- php
- php-cli
- php-apcu
- php7.0-mbstring
# For Composer.
- unzip
# For running tests.
- php7.0-xml
- php-xdebug

# Create necessary databases and database users.
- name: Create database
mysql_db:
name: b2db
encoding: utf8
collation: utf8_general_ci
state: present

- name: Create database user
mysql_user:
name: b2db
host: localhost
password: b2db
priv: 'b2db.*:ALL'
state: present

# Composer dependency installation.
- name: Download composer
get_url:
url: https://getcomposer.org/download/1.8.0/composer.phar
checksum: sha256:0901a84d56f6d6ae8f8b96b0c131d4f51ccaf169d491813d2bcedf2a6e4cefa6
dest: /usr/local/bin/composer
owner: vagrant
group: vagrant
mode: 0755

- name: Install up-to-date development requirements via composer
become_user: vagrant
composer:
command: update
no_dev: no
working_dir: /vagrant

- name: Create convenience symlink for running the phpunit
file:
src: "/vagrant/vendor/bin/phpunit"
dest: "/usr/local/bin/phpunit"
owner: root
group: root
state: link
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
"ext-mbstring" : "*",
"ext-pdo" : "*"
},
"require-dev" : {
"phpunit/phpunit": "^6"
},
"autoload" : {
"psr-4" : {
"b2db\\" : "src/"
Expand Down
23 changes: 23 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php"
colors="true"
verbose="true"
stopOnFailure="false">

<testsuites>
<testsuite name="Test suite">
<directory>tests</directory>
</testsuite>
</testsuites>

<logging>
<log type="coverage-text" target="php://stdout" />
</logging>

<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src/</directory>
</whitelist>
</filter>

</phpunit>
Loading