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 Tests\Feature; use App\Models\User; use Illuminate\Support\Facades\Hash;..
Decoded Output download
<?php
namespace Tests\Feature;
use App\Models\User;
use Illuminate\Support\Facades\Hash;
class ProfileTest extends TestCase
{
public function testUpdateProfileRequiresCurrentPassword(): void
{
$this->putAs('api/me', [
'name' => 'Foo',
'email' => '[email protected]',
])
->assertUnprocessable();
}
public function testUpdateProfileWithoutNewPassword(): void
{
/** @var User $user */
$user = User::factory()->create(['password' => Hash::make('secret')]);
$this->putAs('api/me', [
'name' => 'Foo',
'email' => '[email protected]',
'current_password' => 'secret',
], $user);
$user->refresh();
self::assertSame('Foo', $user->name);
self::assertSame('[email protected]', $user->email);
self::assertTrue(Hash::check('secret', $user->password));
}
public function testUpdateProfileWithNewPassword(): void
{
/** @var User $user */
$user = User::factory()->create(['password' => Hash::make('secret')]);
$token = $this->putAs('api/me', [
'name' => 'Foo',
'email' => '[email protected]',
'new_password' => 'new-secret',
'current_password' => 'secret',
], $user)
->headers
->get('Authorization');
$user->refresh();
self::assertNotNull($token);
self::assertSame('Foo', $user->name);
self::assertSame('[email protected]', $user->email);
self::assertTrue(Hash::check('new-secret', $user->password));
}
}
?>
Did this file decode correctly?
Original Code
<?php
namespace Tests\Feature;
use App\Models\User;
use Illuminate\Support\Facades\Hash;
class ProfileTest extends TestCase
{
public function testUpdateProfileRequiresCurrentPassword(): void
{
$this->putAs('api/me', [
'name' => 'Foo',
'email' => '[email protected]',
])
->assertUnprocessable();
}
public function testUpdateProfileWithoutNewPassword(): void
{
/** @var User $user */
$user = User::factory()->create(['password' => Hash::make('secret')]);
$this->putAs('api/me', [
'name' => 'Foo',
'email' => '[email protected]',
'current_password' => 'secret',
], $user);
$user->refresh();
self::assertSame('Foo', $user->name);
self::assertSame('[email protected]', $user->email);
self::assertTrue(Hash::check('secret', $user->password));
}
public function testUpdateProfileWithNewPassword(): void
{
/** @var User $user */
$user = User::factory()->create(['password' => Hash::make('secret')]);
$token = $this->putAs('api/me', [
'name' => 'Foo',
'email' => '[email protected]',
'new_password' => 'new-secret',
'current_password' => 'secret',
], $user)
->headers
->get('Authorization');
$user->refresh();
self::assertNotNull($token);
self::assertSame('Foo', $user->name);
self::assertSame('[email protected]', $user->email);
self::assertTrue(Hash::check('new-secret', $user->password));
}
}
Function Calls
None |
Stats
MD5 | 52892721541db39a5f6f1f0cb5f6dc6f |
Eval Count | 0 |
Decode Time | 107 ms |