<commit_before><?php

namespace Spec\Minds\Core\Security;

use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Minds\Core;
use Minds\Entities\User;
use Minds\Entities\Entity;
use Minds\Entities\Object;

class ACLSpec extends ObjectBehavior
{
    /** @var Core\Security\RateLimits\Manager */
    private $rateLimits;

    function let(Core\Security\RateLimits\Manager $rateLimits) {
        $this->rateLimits = $rateLimits;

        $this->beConstructedWith($rateLimits);
    }

    public function mock_session($on = true)
    {
        if ($on) {
            $user = new User;
            $user->guid = 123;
            $user->username = 'minds';
        } else {
            $user = null;
        }
        Core\Session::setUser($user);
    }

    public function it_is_initializable()
    {
        $this->shouldHaveType('Minds\Core\Security\ACL');
    }

    public function it_should_allow_read_of_public_entities(Entity $entity)
    {
        $entity->get('access_id')->willReturn(2);
        $entity->get('container_guid')->willReturn(123);
        $entity->get('owner_guid')->willReturn(123);
        $this->read($entity)->shouldReturn(true);
    }

    public function it_should_not_allow_read_of_private_entities(Entity $entity)
    {
        $entity->getType()->willReturn('specy');
        $entity->get('access_id')->willReturn(0);
        $this->read($entity)->shouldReturn(false);
    }

    public function it_should_trigger_acl_read_event(Object $entity)
    {
        $this->mock_session(true);

        Core\Events\Dispatcher::register('acl:read', 'all', function ($event) {
        $event->setResponse(true);
            });
<commit_msg>(fix): acl spec tests require access to type and owner_guid<commit_after><?php

namespace Spec\Minds\Core\Security;

use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Minds\Core;
use Minds\Entities\User;
use Minds\Entities\Entity;
use Minds\Entities\Object;

class ACLSpec extends ObjectBehavior
{
    /** @var Core\Security\RateLimits\Manager */
    private $rateLimits;

    function let(Core\Security\RateLimits\Manager $rateLimits) {
        $this->rateLimits = $rateLimits;

        $this->beConstructedWith($rateLimits);
    }

    public function mock_session($on = true)
    {
        if ($on) {
            $user = new User;
            $user->guid = 123;
            $user->username = 'minds';
        } else {
            $user = null;
        }
        Core\Session::setUser($user);
    }

    public function it_is_initializable()
    {
        $this->shouldHaveType('Minds\Core\Security\ACL');
    }

    public function it_should_allow_read_of_public_entities(Entity $entity)
    {
        $entity->get('access_id')->willReturn(2);
        $entity->get('container_guid')->willReturn(123);
        $entity->get('owner_guid')->willReturn(123);
        $entity->get('type')->willReturn('activity');
        $this->read($entity)->shouldReturn(true);
    }

    public function it_should_not_allow_read_of_private_entities(Entity $entity)
    {
        $entity->getType()->willReturn('specy');
        $entity->get('access_id')->willReturn(0);
        $entity->get('owner_guid')->willReturn(123);
        $entity->get('type')->willReturn('activity');
        $this->read($entity)->shouldReturn(false);
    }

    public function it_should_trigger_acl_read_event(Object $entity)
    {
        $this->mock_session(true);

        Core\Events\Dispatcher::register('acl:read', 'all', function ($event) {
        $event->setResponse(true);
            });

{'fraction_non_alphanumeric': 0.14666666666666667, 'fraction_numerical': 0.0070921985815602835, 'mean_word_length': 2.930880713489409, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 51, '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': '6693799', 'n_tokens_mistral': 1108, 'n_tokens_neox': 1081, 'n_words': 162}