Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
codemasher committed Jun 21, 2018
1 parent 6ed1677 commit 5281b11
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions tests/ImagetilerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php
/**
* Class ImagetilerTest
*
* @filesource ImagetilerTest.php
* @created 20.06.2018
* @package chillerlan\ImagetilerTest
* @author smiley <[email protected]>
* @copyright 2018 smiley
* @license MIT
*/

namespace chillerlan\ImagetilerTest;

use chillerlan\Imagetiler\Imagetiler;
use chillerlan\Imagetiler\ImagetilerOptions;
use PHPUnit\Framework\TestCase;
use ReflectionClass, ReflectionMethod;

/**
*/
class ImagetilerTest extends TestCase{

/**
* @var \ReflectionClass
*/
protected $reflection;

protected function setUp(){
$this->reflection = new ReflectionClass(Imagetiler::class);
}

public function testGetSize(){

$max = 22;

$options = new ImagetilerOptions([
'zoom_min' => 0,
'zoom_max' => $max,
'zoom_normalize' => 4,
]);

$tiler = new Imagetiler($options);

for($z = 0; $z <= $max; $z++){
$v = $this->getMethod('getSize')->invokeArgs($tiler, [4096, 2048, $z]);

$expected = 2 ** $z * 256;

$this->assertSame($expected, $v[0]);
$this->assertSame($expected/2, $v[1]);
}

}

/**
* @param string $method
*
* @return \ReflectionMethod
*/
protected function getMethod(string $method):ReflectionMethod {
$method = $this->reflection->getMethod($method);
$method->setAccessible(true);

return $method;
}


}

0 comments on commit 5281b11

Please sign in to comment.