<commit_before><?php

namespace PhpAbac\Test;

use PhpAbac\Abac;

class AbacTest extends AbacTestCase {
    /** @var Abac **/
    protected $abac;
    
    public function setUp() {
        $this->abac = new Abac(new \PDO(
            'mysql:host=' . $GLOBALS['MYSQL_DB_HOST'] . ';' .
            'dbname=' . $GLOBALS['MYSQL_DB_DBNAME'],
            $GLOBALS['MYSQL_DB_USER'],
            $GLOBALS['MYSQL_DB_PASSWD'],
            [
                \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION
            ]
        ));
        $this->loadFixture('policy_rules');
    }
    
    public function tearDown() {
        Abac::clearContainer();
    }
    
    public function testEnforce() {
        $this->assertTrue($this->abac->enforce('nationality-access', 1));
        $this->assertFalse($this->abac->enforce('nationality-access', 2));
    }
    
    public function testContainer() {
        $item = new \stdClass();
        $item->property = 'test';
        // Test Set method<commit_msg>Add the new test cases<commit_after><?php

namespace PhpAbac\Test;

use PhpAbac\Abac;

class AbacTest extends AbacTestCase {
    /** @var Abac **/
    protected $abac;
    
    public function setUp() {
        $this->abac = new Abac(new \PDO(
            'mysql:host=' . $GLOBALS['MYSQL_DB_HOST'] . ';' .
            'dbname=' . $GLOBALS['MYSQL_DB_DBNAME'],
            $GLOBALS['MYSQL_DB_USER'],
            $GLOBALS['MYSQL_DB_PASSWD'],
            [
                \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION
            ]
        ));
        $this->loadFixture('policy_rules');
    }
    
    public function tearDown() {
        Abac::clearContainer();
    }
    
    public function testEnforce() {
        $this->assertTrue($this->abac->enforce('nationality-access', 1));
        $this->assertFalse($this->abac->enforce('nationality-access', 2));
        
        $this->assertTrue($this->abac->enforce('vehicle-homologation', 1, 1));
        $this->assertFalse($this->abac->enforce('vehicle-homologation', 3, 2));
        $this->assertFalse($this->abac->enforce('vehicle-homologation', 4, 4));
    }
    
    public function testContainer() {
        $item = new \stdClass();
        $item->property = 'test';
        // Test Set method
{'fraction_non_alphanumeric': 0.16092981671881984, 'fraction_numerical': 0.004470272686633884, 'mean_word_length': 2.2294372294372296, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 32, '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': '753322', 'n_tokens_mistral': 735, 'n_tokens_neox': 728, 'n_words': 114}