示例#1
0
 public function testShouldDraw()
 {
     $generator = new Hash();
     $generator->hash('x');
     $generator_x = new Hash();
     $generator_x->hash('x');
     $layout = M::mock(Layout::class, [$generator]);
     $reflection = new ReflectionClass(Layout::class);
     $method = $reflection->getMethod('shouldDraw');
     $method->setAccessible(true);
     $expected = (bool) $generator_x->next(1, 1) % 2;
     $actual = $method->invokeArgs($layout, [[false, true], 1, 1]);
     $this->assertEquals($expected, $actual);
 }
示例#2
0
 public function testDifferentHash()
 {
     $generator_a = new Hash();
     $generator_a->hash('N***A');
     $generator_b = new Hash();
     $generator_b->hash('WHITE N***A');
     $seq_a = [];
     $seq_b = [];
     $cycles = 10;
     while ($cycles--) {
         array_push($seq_a, $generator_a->next($cycles, -1 * $cycles));
         array_push($seq_b, $generator_b->next($cycles, -1 * $cycles));
     }
     $this->assertNotEquals($seq_a, $seq_b);
 }
示例#3
0
 public function testPlotting()
 {
     $size = 4;
     $max_columns = $size / 2;
     $generator = new Hash();
     $generator->hash('X');
     $generator_b = new Hash();
     $generator_b->hash('X');
     $layout = new VerticalMirror($generator);
     $layout->columns($size);
     $layout->rows($size);
     $grid = $layout->drawGrid();
     for ($y = 0; $y < $size; $y++) {
         for ($x = 0; $x < $max_columns; $x++) {
             $this->assertEquals((bool) ($generator_b->next(0, 0) % 2), $grid[$y][$x]);
         }
     }
 }