dchadwick/web/modules/custom/ufc/tests/src/Kernel/WebScraperKernelTest.php
2025-10-15 22:49:16 -04:00

45 lines
7.4 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
declare(strict_types=1);
namespace Drupal\Tests\ufc\Kernel;
use Drupal\Tests\UnitTestCase;
use Symfony\Component\DomCrawler\Crawler;
/**
* @coversDefaultClass \Drupal\ufc\Services\FightImporter
* @group ufc
*/
class WebScraperKernelTest extends UnitTestCase {
protected $fighterImporter;
protected $fighter;
protected $crawler;
public function setUp(): void {
parent::setUp();
$this->fighterImporter = $this->createMock('Drupal\ufc\Services\FighterImporter');
$this->fighter = $this->createMock('Drupal\ufc\Fighter');
$this->crawler = $this->createMock('Symfony\Component\DomCrawler\Crawler');
}
/**
* @dataProvider extractFighterNamesDataProvider
*/
public function testValidFighter($test_input) {
$this->fighter->first_name = 'scott';
$this->fighter->crawler = new Crawler($test_input);
$this->fighter->setAge();
dump($this->fighter->first_name);
$this->assertEquals("1", 2, "These do not match.");
}
public static function extractFighterNamesDataProvider(): array {
return [
['<div class="faq-athlete__tabs"><section class="c-tabs c-tabs--athlete" aria-multiselectable="false"><ul class="c-tabs__nav c-tabs__nav--n-4" role="tablist"><li class="c-tabs__nav-item is-active" role="presentation"><button role="tab" aria-setsize="3" aria-posinset="1" aria-controls="tab-panel-1" aria-selected="1" tabindex="" class="btn c-tabs__nav-btn">Bio</button></li><li class="c-tabs__nav-item" role="presentation"><button role="tab" aria-setsize="3" aria-posinset="2" aria-controls="tab-panel-2" aria-selected="" tabindex="-1" class="btn c-tabs__nav-btn">Fighter Facts</button></li><li class="c-tabs__nav-item" role="presentation"><button role="tab" aria-setsize="3" aria-posinset="3" aria-controls="tab-panel-3" aria-selected="" tabindex="-1" class="btn c-tabs__nav-btn">UFC History</button></li><li class="c-tabs__nav-item" role="presentation"><button role="tab" aria-setsize="3" aria-posinset="4" aria-controls="tab-panel-4" aria-selected="" tabindex="-1" class="btn c-tabs__nav-btn">Q&amp;A</button></li></ul><div class="c-tabs__mobile-nav"><label for="tab-1470598336">Choose tab:</label><select class="c-tabs__select" id="tab-1470598336"><option value="tab-label-1">Bio</option><option value="tab-label-2">Fighter Facts</option><option value="tab-label-3">UFC History</option><option value="tab-label-4">Q&amp;A</option></select></div><div class="c-tabs__panes"><div class="c-tabs__pane is-current" id="tab-panel-1" role="tabpanel" aria-labelledby="tab-label-1" tabindex="-1"><div class="c-tabs__pane-body"><div class="c-bio c-bio--athlete"><div class="c-bio__content"><div class="c-bio__info"><div class="c-bio__info-details"><div class="c-bio__row--1col"><div class="c-bio__field"><div class="c-bio__label">Status</div><div class="c-bio__text">Active</div></div></div><div class="c-bio__row--2col"><div class="c-bio__field c-bio__field--border-bottom-small-screens"><div class="c-bio__label">Fighting style</div><div class="c-bio__text">Wrestler</div></div></div><div class="c-bio__row--3col"><div class="c-bio__field"><div class="c-bio__label">Age</div><div class="c-bio__text"><div class="field field--name-age field--type-integer field--label-hidden field__item">31</div></div></div><div class="c-bio__field"><div class="c-bio__label">Height</div><div class="c-bio__text">74.00</div></div><div class="c-bio__field"><div class="c-bio__label">Weight</div><div class="c-bio__text">183.00</div></div></div><div class="c-bio__row--3col"><div class="c-bio__field"><div class="c-bio__label">Octagon Debut</div><div class="c-bio__text">Jul. 15, 2020</div></div><div class="c-bio__field"><div class="c-bio__label">Reach</div><div class="c-bio__text">75.00</div></div><div class="c-bio__field"><div class="c-bio__label">Leg reach</div><div class="c-bio__text">40.00</div></div></div></div></div></div></div></div></div><div class="c-tabs__pane" id="tab-panel-2" role="tabpanel" aria-labelledby="tab-label-2" tabindex="-1"><div class="c-tabs__pane-body"><div class="field field--name-qna-facts field--type-text-long field--label-hidden field__item"><ul><li>Pro since 2018<br>&nbsp;</li><li>Six wins by KO, six by submission (Heel hook, 2 DArce choke, 2 RNC, face crank)<br>&nbsp;</li><li>Nine first round finishes<br>&nbsp;</li><li>Origin of nickname: “Means Wolf in Chechen.”</li></ul></div></div></div><div class="c-tabs__pane" id="tab-panel-3" role="tabpanel" aria-labelledby="tab-label-3" tabindex="-1"><div class="c-tabs__pane-body"><div class="field field--name-qna-ufc field--type-text-long field--label-hidden field__item"><p><strong>UFC 319</strong>(10/16/25) Chimaev won a five round unanimous decision over Dricus Du Plessis to win the UFC middleweight title</p><p><strong>UFC 308</strong>(10/30/24) Chimaev submitted Robert Whittaker via face crank at 3:34 of the first round</p><p><strong>UFC 294</strong>(10/21/23) Chimaev won a three round majority decision over Kamaru Usman</p><p><strong>UFC 279</strong>(9/10/22) Chimaev submitted Kevin Holland via DArce choke at 2:13 of the first round&nbsp;</p><p><strong>UFC 273</strong>(4/9/22) Chimaev won a three round unanimous decision over Gilbert Burns</p><p><strong>UFC 267</strong>(10/30/21) Chimaev submitted Li Jingliang via rear naked choke at 3:16 of the first round</p><p><strong>UFC Fight Night</strong>(9/19/20) Chimaev knocked out Gerald Meerschaert at :17 of the first round</p><p><strong>UFC on ESPN</strong>(7/25/20) Chimaev stopped Rhys McKee via strikes at 3:09 of the first round</p><p><strong>UFC Fight Night</strong>(7/15/20) Chimaev submitted John Phillips via DArce choke at 1:12 of the second round</p></div></div></div><div class="c-tabs__pane" id="tab-panel-4" role="tabpanel" aria-labelledby="tab-label-4" tabindex="-1"><div class="c-tabs__pane-body"><div class="field field--name-qna field--type-text-long field--label-hidden field__item"><p><strong>When and why did you start training for fighting?</strong>&nbsp;I am a competitive person and have competed my whole life. When I was younger it was wrestling, and when I moved to Sweden, I kept wrestling. After a few national championships I won a gift card at a hotel in Stockholm. I came during a weekend and went to Allstars and tried MMA. I felt that this was something for me and when I went back to Kalmar, I decided to quit my job and move to Stockholm.</p><p><strong>Training</strong>: A typical day starts with early jogging at 5am and then some more hours of sleep. I then wake up at 8:30am have a bit of breakfast and get ready for early training at 10am with the team.</p><p><strong>What ranks and titles have you held?</strong>&nbsp;Swedish National champion in freestyle wrestling, brown belt in BJJ&nbsp;</p><p><strong>What does it mean for you to fight in the UFC?</strong>&nbsp;It means that all the hard work and sacrifices that have been made are worth it now when I belong to the best fighting organization in the world. Finally, I can show to the world what I am capable of.</p><p><strong>What was your job before you started fighting?</strong>&nbsp;I worked in a small poultry factory in the small town of Kalmar and did some security work in Stockholm when I started fighting.</p><p><strong>Specific accomplishments in amateur competition?</strong>&nbsp;I went undefeated (4-0) as an amateur in MMA with all finishes.</p><p><strong>Favorite grappling technique:</strong>No favorite. As long as the opponent taps, its the favorite.&nbsp;</p></div></div></div></div></section></div>']
];
}
}