Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php namespace Illuminate\Tests\Integration\Events; use Illuminate\Database\DatabaseTra..
Decoded Output download
<?php
namespace Illuminate\Tests\Integration\Events;
use Illuminate\Database\DatabaseTransactionsManager;
use Illuminate\Support\Facades\Event;
use Mockery as m;
use Orchestra\Testbench\TestCase;
class ListenerTest extends TestCase
{
protected function tearDown(): void
{
parent::tearDown();
ListenerTestListener::$ran = false;
ListenerTestListenerAfterCommit::$ran = false;
parent::tearDown();
}
public function testClassListenerRunsNormallyIfNoTransactions()
{
$this->app->singleton('db.transactions', function () {
$transactionManager = m::mock(DatabaseTransactionsManager::class);
$transactionManager->shouldNotReceive('addCallback')->once()->andReturn(null);
return $transactionManager;
});
Event::listen(ListenerTestEvent::class, ListenerTestListener::class);
Event::dispatch(new ListenerTestEvent);
$this->assertTrue(ListenerTestListener::$ran);
}
public function testClassListenerDoesntRunInsideTransaction()
{
$this->app->singleton('db.transactions', function () {
$transactionManager = m::mock(DatabaseTransactionsManager::class);
$transactionManager->shouldReceive('addCallback')->once()->andReturn(null);
return $transactionManager;
});
Event::listen(ListenerTestEvent::class, ListenerTestListenerAfterCommit::class);
Event::dispatch(new ListenerTestEvent);
$this->assertFalse(ListenerTestListenerAfterCommit::$ran);
}
}
class ListenerTestEvent
{
//
}
class ListenerTestListener
{
public static $ran = false;
public function handle()
{
static::$ran = true;
}
}
class ListenerTestListenerAfterCommit
{
public static $ran = false;
public $afterCommit = true;
public function handle()
{
static::$ran = true;
}
}
?>
Did this file decode correctly?
Original Code
<?php
namespace Illuminate\Tests\Integration\Events;
use Illuminate\Database\DatabaseTransactionsManager;
use Illuminate\Support\Facades\Event;
use Mockery as m;
use Orchestra\Testbench\TestCase;
class ListenerTest extends TestCase
{
protected function tearDown(): void
{
parent::tearDown();
ListenerTestListener::$ran = false;
ListenerTestListenerAfterCommit::$ran = false;
parent::tearDown();
}
public function testClassListenerRunsNormallyIfNoTransactions()
{
$this->app->singleton('db.transactions', function () {
$transactionManager = m::mock(DatabaseTransactionsManager::class);
$transactionManager->shouldNotReceive('addCallback')->once()->andReturn(null);
return $transactionManager;
});
Event::listen(ListenerTestEvent::class, ListenerTestListener::class);
Event::dispatch(new ListenerTestEvent);
$this->assertTrue(ListenerTestListener::$ran);
}
public function testClassListenerDoesntRunInsideTransaction()
{
$this->app->singleton('db.transactions', function () {
$transactionManager = m::mock(DatabaseTransactionsManager::class);
$transactionManager->shouldReceive('addCallback')->once()->andReturn(null);
return $transactionManager;
});
Event::listen(ListenerTestEvent::class, ListenerTestListenerAfterCommit::class);
Event::dispatch(new ListenerTestEvent);
$this->assertFalse(ListenerTestListenerAfterCommit::$ran);
}
}
class ListenerTestEvent
{
//
}
class ListenerTestListener
{
public static $ran = false;
public function handle()
{
static::$ran = true;
}
}
class ListenerTestListenerAfterCommit
{
public static $ran = false;
public $afterCommit = true;
public function handle()
{
static::$ran = true;
}
}
Function Calls
None |
Stats
MD5 | 4a2a17baff46df53a81b6612b5b0fdeb |
Eval Count | 0 |
Decode Time | 98 ms |