Exemple #1
0
 /**
  * Test multiple conversions
  *
  * @todo move this test to a better place
  *
  * @since 0.4.0
  *
  * @group bandit
  * @group group
  * @group front_ui
  *
  * @covers ingot_register_conversion()
  */
 public function testMultipleConversions()
 {
     $groups = ingot_tests_data::click_link_group(true, 1, 3);
     $group_id = $groups['ids'][0];
     $variants = $groups['variants'][$groups['ids'][0]];
     $expected = [];
     foreach ($variants as $variant) {
         $expected[$variant] = ['n' => 0, 'd' => 0];
     }
     for ($i = 0; $i <= 25; $i++) {
         $chosen = $this->check_render($groups);
         if (in_array($i, [2, 3, 5, 8, 13, 21])) {
             ingot_register_conversion($chosen);
             $expected[$chosen]['n'] = $expected[$chosen]['n'] + 1;
         }
         $expected[$chosen]['d'] = $expected[$chosen]['d'] + 1;
         $levers = \ingot\testing\crud\group::get_levers($group_id);
         /** @var \MaBandit\Lever $lever */
         foreach ($levers[$group_id] as $id => $lever) {
             if ($chosen != $id) {
                 $this->assertSame($expected[$id]['n'], $lever->getNumerator(), $id . '-' . $lever->getNumerator());
                 $this->assertSame($expected[$id]['d'], $lever->getDenominator(), $id);
             }
         }
     }
 }