<?php
namespace Ayeo\Barcode\Test\Utils;

use Ayeo\Barcode\Utils\ScaleCalculator;

class ScaleCalculatorTest extends \PHPUnit_Framework_TestCase
{
    public function testBase()
    {
        $calculator = $this->getCalculator();
        $bars = '1101001110011110101110110010001001011001110010001011000111000101101111010111011000101000110011011001110101111010011100110101111001001100011101011';
        $this->assertEquals(3, $calculator->getBarWidth(500, $bars));
    }

    /**
     * @expectedException           \RuntimeException
     * @expectedExceptionMessage    Barcode is to long for given width
     */
    public function testToLongCode()
    {
        $calculator = $this->getCalculator();
        $bars = '1101001110011110101110110010001001011001110010001011000111000101101111010111011000101000110011011001110101111010011100110101111001001100011101011110100111001111010111011001000100101100111001000101100011100010110111101011101100010111010011100111101011101100100010010110011100100010110001110001011011110101110110001010110100111001111010111011001000100101100111001000101100011100010110111101011101100010100011001101100111010111101001110011010111100100110001110101100110011011001110101111010011100110101111001001100011101011000110011011001110101111010011100110101111001001100011101011';
        $calculator->getBarWidth(100, $bars);
    }

    /**
     * @return ScaleCalculator
     */
    private function getCalculator()
    {
        $calculator = new ScaleCalculator();
        return $calculator;
    }

}