Skip to content

Commit dccfb0b

Browse files
author
Martin Brecht-Precht
committed
Prepared the structure for testing.
Modified the QrEncoder class. Added QrEncoderTest.
1 parent 39c78d0 commit dccfb0b

22 files changed

+254
-2
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/vendor
2-
composer.lock
2+
composer.lock
3+
vagrantfile

.travis.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
language: php
2+
3+
before_install:
4+
- sudo apt-get -qq update
5+
- sudo apt-get install -y qrencode
6+
- pear config-set preferred_state beta
7+
- printf "\n" | pecl install imagick
8+
- echo "extension=imagick.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
9+
- php -m
10+
11+
branches:
12+
only:
13+
- master
14+
15+
php:
16+
- '5.3'
17+
- '5.4'
18+
- '5.5'
19+
- '7.0'
20+
- hhvm
21+
22+
install:
23+
- composer install
24+
25+
matrix:
26+
allow_failures:
27+
- php: hhvm
28+
- php: '5.3'

CONTRIBUTING.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,33 @@ Any bugfix that doesn’t include a test proving the existence of the bug being
6868

6969
We’ve found that test-first development really helps make features better architected and identifies potential edge cases earlier instead of later. Writing tests before the implementation is strongly encouraged.
7070

71+
Sometimes testing is hard because it is not possible to create an environment on the developers machine to fulfill the softwares requirements in the middleware setup. For example installing imagick on Mac OS X could be a task straight out of hell. In this case it is useful to provide a out-of-the-box running machine setup like [docker](https://www.docker.com/) ot [vagrant](https://www.vagrantup.com/) and run tests on the virtual machine via the commandline interface.
72+
73+
## Contributing requirements
74+
75+
For development purposes there is a [vagrant](https://www.vagrantup.com/) setup included in the repo to fulfill the server side requirements easily.
76+
77+
### Installation and testing example (Mac OS X)
78+
79+
#### Installation of vagrant
80+
81+
Get your vagrant version from [https://www.vagrantup.com/downloads.html](https://www.vagrantup.com/downloads.html) and run the installer.
82+
83+
#### Starting the virtual machine and connect via SSH
84+
85+
```
86+
cd php-qr-code-suite
87+
vagrant up
88+
vagrant ssh
89+
```
90+
91+
#### Running the tests via command line interface
92+
93+
```
94+
cd /var/www/php-qr-code-suite
95+
phpunit --bootstrap vendor/autoload.php --configuration phpunit.xml.dist
96+
```
97+
7198
## Full example
7299

73100
Here’s an example workflow for `php-qr-code-suite` hosted on Github, which is currently in version 2.0.x. Your username is `yourname` and you’re submitting a basic bugfix.

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,15 @@
2424
],
2525
"autoload": {
2626
"psr-4": {
27-
"QrCodeSuite\\": ""
27+
"QrCodeSuite\\": "src/"
2828
}
2929
},
3030
"require": {
3131
"php": ">=5.3",
3232
"ext-gd": "*",
3333
"ext-imagick": "*"
34+
},
35+
"require-dev": {
36+
"phpunit/phpunit": "~4.8"
3437
}
3538
}

phpunit.xml.dist

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit colors="true" bootstrap="vendor/autoload.php">
3+
<testsuites>
4+
<testsuite name="QR Code Suite Testsuite">
5+
<directory>test</directory>
6+
</testsuite>
7+
</testsuites>
8+
</phpunit>

QrEncode/QrCode/QrCode.php renamed to src/QrEncode/QrCode/QrCode.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,12 @@ public function replaceRow($index, QrCodePointRow $row)
142142
return $this;
143143
}
144144

145+
/**
146+
* @return int
147+
*/
148+
public function countRows()
149+
{
150+
return count($this->rows);
151+
}
152+
145153
}
File renamed without changes.

QrEncode/QrCode/QrCodePointRow.php renamed to src/QrEncode/QrCode/QrCodePointRow.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,12 @@ public function replacePoint($index, QrCodePoint $point)
8080
return $this;
8181
}
8282

83+
/**
84+
* @return int
85+
*/
86+
public function countPoints()
87+
{
88+
return count($this->points);
89+
}
90+
8391
}
File renamed without changes.

0 commit comments

Comments
 (0)