added phpunit

This commit is contained in:
smiley
2016-02-08 13:38:00 +01:00
parent f506bf573d
commit 3b36574219
3 changed files with 82 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
language: php
php:
- 5.6
- 7.0
install: travis_retry composer install --no-interaction --prefer-source
script: vendor/bin/phpunit tests --coverage-clover clover.xml --whitelist src
after_script: bash <(curl -s https://codecov.io/bash)
+23
View File
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
<testsuites>
<testsuite name="php-qrcode test suite">
<file>tests/BitBufferTest.php</file>
</testsuite>
</testsuites>
</phpunit>
+48
View File
@@ -0,0 +1,48 @@
<?php
/**
* @filesource BitBufferTest.php
* @created 08.02.2016
* @author Smiley <smiley@chillerlan.net>
* @copyright 2015 Smiley
* @license MIT
*/
use chillerlan\QRCode\BitBuffer;
use chillerlan\QRCode\QRConst;
class BitBufferTest extends PHPUnit_Framework_TestCase{
/**
* @var \chillerlan\QRCode\BitBuffer
*/
protected $bitBuffer;
protected function setUp(){
$this->bitBuffer = new BitBuffer;
}
public function bitProvider(){
return [
[QRConst::MODE_NUMBER, 16],
[QRConst::MODE_ALPHANUM, 32],
[QRConst::MODE_BYTE, 64],
[QRConst::MODE_KANJI, 128],
];
}
/**
* @dataProvider bitProvider
*/
public function testPut($data, $value){
$this->bitBuffer->put($data, 4);
$this->assertEquals($value, $this->bitBuffer->buffer[0]);
$this->assertEquals(4, $this->bitBuffer->length);
}
public function testClear(){
$this->bitBuffer->clear();
$this->assertEquals([], $this->bitBuffer->buffer);
$this->assertEquals(0, $this->bitBuffer->length);
}
}