<commit_before><?php

namespace SilverStripe\BehatExtension\Tests;

use Behat\Mink\Element\DocumentElement;
use Behat\Mink\Selector\SelectorsHandler;
use Behat\Mink\Session;
use Behat\Mink\Mink;
use Behat\Mink\Driver\DriverInterface;
use Behat\Mink\Element\Element;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use SilverStripe\BehatExtension\Tests\SilverStripeContextTest\FeatureContext;
use SilverStripe\Dev\SapphireTest;

class SilverStripeContextTest extends TestCase
{

    protected $backupGlobals = false;

    public static function setUpBeforeClass(): void
    {
        // Bootstrap test environment
        parent::setUpBeforeClass();
        SapphireTest::start();
    }

    /**
     * @expectedException \LogicException
     * @expectedExceptionMessage Cannot find 'region_map' in the behat.yml
     */
    public function testGetRegionObjThrowsExceptionOnUnknownSelector()
    {
        $context = $this->getContextMock();
        $context->getRegionObj('.unknown');
    }

    /**
     * @expectedException \LogicException
     * @expectedExceptionMessage Cannot find the specified region in the behat.yml
     */
    public function testGetRegionObjThrowsExceptionOnUnknownRegion()
    {
        $context = $this->getContextMock();
        $context->setRegionMap(array('MyRegion' => '.my-region'));
        $context->getRegionObj('.unknown');
    }

    public function testGetRegionObjFindsBySelector()
    {
        $context = $this->getContextMock();
        $context->getSession()->getPage()
            ->expects($this->any())
            ->method('find')
            ->will($this->returnValue($this->getElementMock()));
        $obj = $context->getRegionObj('.some-selector');
        $this->assertNotNull($obj);
    }<commit_msg>PHPunit deprecations<commit_after><?php

namespace SilverStripe\BehatExtension\Tests;

use Behat\Mink\Element\DocumentElement;
use Behat\Mink\Selector\SelectorsHandler;
use Behat\Mink\Session;
use Behat\Mink\Mink;
use Behat\Mink\Driver\DriverInterface;
use Behat\Mink\Element\Element;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use SilverStripe\BehatExtension\Tests\SilverStripeContextTest\FeatureContext;
use SilverStripe\Dev\SapphireTest;

class SilverStripeContextTest extends TestCase
{

    protected $backupGlobals = false;

    public static function setUpBeforeClass(): void
    {
        // Bootstrap test environment
        parent::setUpBeforeClass();
        SapphireTest::start();
    }

    public function testGetRegionObjThrowsExceptionOnUnknownSelector()
    {
        $this->expectException(\LogicException::class);
        $this->expectExceptionMessage('Cannot find \'region_map\' in the behat.yml');
        $context = $this->getContextMock();
        $context->getRegionObj('.unknown');
    }

    public function testGetRegionObjThrowsExceptionOnUnknownRegion()
    {
        $this->expectException(\LogicException::class);
        $this->expectExceptionMessage('Cannot find the specified region in the behat.yml');
        $context = $this->getContextMock();
        $context->setRegionMap(array('MyRegion' => '.my-region'));
        $context->getRegionObj('.unknown');
    }

    public function testGetRegionObjFindsBySelector()
    {
        $context = $this->getContextMock();
        $context->getSession()->getPage()
            ->expects($this->any())
            ->method('find')
            ->will($this->returnValue($this->getElementMock()));
        $obj = $context->getRegionObj('.some-selector');
        $this->assertNotNull($obj);
    }
{'fraction_non_alphanumeric': 0.12580016699137211, 'fraction_numerical': 0.0, 'mean_word_length': 3.572519083969466, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2962246', 'n_tokens_mistral': 1026, 'n_tokens_neox': 1006, 'n_words': 171}