<commit_before><?php

/**
 * Class AspectLogExceptionsTest
 */
class AspectLogExceptionsTest extends \AspectTestCase
{
    /** @var \Ytake\LaravelAspect\AspectManager $manager */
    protected $manager;

    /** @var Illuminate\Log\Writer */
    protected $log;

    /** @var \Illuminate\Filesystem\Filesystem */
    protected $file;

    protected function setUp()
    {
        parent::setUp();
        $this->manager = new \Ytake\LaravelAspect\AspectManager($this->app);
        $this->resolveManager();
        $this->log = $this->app['Psr\Log\LoggerInterface'];
        $this->file = $this->app['files'];
        if (!$this->file->exists($this->getDir())) {
            $this->file->makeDirectory($this->getDir());
        }
    }

    /**
     * @expectedException \Exception
     * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
     */
    public function testDefaultLogger()
    {
        $this->log->useFiles($this->getDir() . '/.testing.exceptions.log');
        /** @var \__Test\AspectLoggable $cache */
        $cache = $this->app->make(\__Test\AspectLogExceptions::class);
        $cache->normalLog(1);
    }

    public function testShouldBeLogger()
    {
        $this->log->useFiles($this->getDir() . '/.testing.exceptions.log');
        /** @var \__Test\AspectLoggable $cache */
        $cache = $this->app->make(\__Test\AspectLogExceptions::class);
        try {
            $cache->normalLog(1);
        } catch (\Exception $e) {
            $put = $this->file->get($this->getDir() . '/.testing.exceptions.log');
            $this->assertContains('LogExceptions:__Test\AspectLogExceptions.normalLog', $put);
            $this->assertContains('"code":0,"error_message":"', $put);
        }
    }

    public function testNoException()
    {
        /** @var \__Test\AspectLogExceptions $cache */
        $cache = $this->app->make(\__Test\AspectLogExceptions::class);
        $this->assertSame(1, $cache->noException());
    }

    public function testExpectException()
    {
        $this->log->useFiles($this->getDir() . '/.testing.exceptions.log');
        /** @var \__Test\AspectLogExceptions $cache */
        $cache = $this->app->make(\__Test\AspectLogExceptions::class);
        try {
            $cache->expectException();
        } catch (\LogicException $e) {
            $put = $this->file->get($this->getDir() . '/.testing.exceptions.log');
            $this->assertContains('LogExceptions:__Test\AspectLogExceptions.expectException', $put);
            $this->assertContains('"code":0,"error_message":"', $put);
        }
    }

    public function testShouldNotPutExceptionLoggerFile()
    {
        $this->log->useFiles($this->getDir() . '/.testing.exceptions.log');
        /** @var \__Test\AspectLogExceptions $logger */
        $logger = $this->app->make(\__Test\AspectLogExceptions::class);
        try {
            $logger->expectNoException();
        } catch (\Ytake\LaravelAspect\Exception\FileNotFoundException $e) {
            $this->assertFileNotExists($this->getDir() . '/.testing.exceptions.log');
        }
    }

    public function testShouldNotThrowableException()
    {
        /** @var \__Test\AspectLogExceptions $logger */
        $logger = $this->app->make(\__Test\AspectLogExceptions::class);
        $this->assertSame(1, $logger->noException());
    }

    public function tearDown()
    {
        $this->file->deleteDirectory($this->getDir());
        parent::tearDown();
    }

    /**
     *
     */
    protected function resolveManager()<commit_msg>for tavis test<commit_after><?php

/**
 * Class AspectLogExceptionsTest
 */
class AspectLogExceptionsTest extends \AspectTestCase
{
    /** @var \Ytake\LaravelAspect\AspectManager $manager */
    protected $manager;

    /** @var Illuminate\Log\Writer */
    protected $log;

    /** @var \Illuminate\Filesystem\Filesystem */
    protected $file;

    protected function setUp()
    {
        parent::setUp();
        $this->manager = new \Ytake\LaravelAspect\AspectManager($this->app);
        $this->resolveManager();
        $this->log = $this->app['Psr\Log\LoggerInterface'];
        $this->file = $this->app['files'];
        if (!$this->file->exists($this->getDir())) {
            $this->file->makeDirectory($this->getDir());
        }
    }

    /**
     * @expectedException \Exception
     * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
     */
    public function testDefaultLogger()
    {
        $this->log->useFiles($this->getDir() . '/.testing.exceptions.log');
        /** @var \__Test\AspectLoggable $cache */
        $cache = $this->app->make(\__Test\AspectLogExceptions::class);
        $cache->normalLog(1);
        $this->file->deleteDirectory($this->getDir());
    }

    public function testShouldBeLogger()
    {
        $this->log->useFiles($this->getDir() . '/.testing.exceptions.log');
        /** @var \__Test\AspectLoggable $cache */
        $cache = $this->app->make(\__Test\AspectLogExceptions::class);
        try {
            $cache->normalLog(1);
        } catch (\Exception $e) {
            $put = $this->file->get($this->getDir() . '/.testing.exceptions.log');
            $this->assertContains('LogExceptions:__Test\AspectLogExceptions.normalLog', $put);
            $this->assertContains('"code":0,"error_message":"', $put);
        }
        $this->file->deleteDirectory($this->getDir());
    }

    public function testNoException()
    {
        /** @var \__Test\AspectLogExceptions $cache */
        $cache = $this->app->make(\__Test\AspectLogExceptions::class);
        $this->assertSame(1, $cache->noException());
    }

    public function testExpectException()
    {
        $this->log->useFiles($this->getDir() . '/.testing.exceptions.log');
        /** @var \__Test\AspectLogExceptions $cache */
        $cache = $this->app->make(\__Test\AspectLogExceptions::class);
        try {
            $cache->expectException();
        } catch (\LogicException $e) {
            $put = $this->file->get($this->getDir() . '/.testing.exceptions.log');
            $this->assertContains('LogExceptions:__Test\AspectLogExceptions.expectException', $put);
            $this->assertContains('"code":0,"error_message":"', $put);
        }
        $this->file->deleteDirectory($this->getDir());
    }

    public function testShouldNotPutExceptionLoggerFile()
    {
        $this->log->useFiles($this->getDir() . '/.testing.exceptions.log');
        /** @var \__Test\AspectLogExceptions $logger */
        $logger = $this->app->make(\__Test\AspectLogExceptions::class);
        try {
            $logger->expectNoException();
        } catch (\Ytake\LaravelAspect\Exception\FileNotFoundException $e) {
            $this->assertFileNotExists($this->getDir() . '/.testing.exceptions.log');
        }
        $this->file->deleteDirectory($this->getDir());
    }

    public function testShouldNotThrowableException()
    {
        /** @var \__Test\AspectLogExceptions $logger */
        $logger = $this->app->make(\__Test\AspectLogExceptions::class);
        $this->assertSame(1, $logger->noException());
    }

    /**
     *
     */
    protected function resolveManager()
{'fraction_non_alphanumeric': 0.1761744966442953, 'fraction_numerical': 0.0016778523489932886, 'mean_word_length': 2.605342741935484, 'pattern_counts': {'":': 8, '<': 5, '<?xml version=': 0, '>': 132, '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': '5899390', 'n_tokens_mistral': 2147, 'n_tokens_neox': 2135, 'n_words': 278}