PHP code example of ohseesoftware / laravel-assert-encrypted

1. Go to this page and download the library: Download ohseesoftware/laravel-assert-encrypted library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ohseesoftware / laravel-assert-encrypted example snippets


User::create([
    'name' => 'John Doe',
    'secret' => encrypt('api-key')
]);



namespace Tests;

use OhSeeSoftware\LaravelAssertEncrypted\Traits\AssertEncrypted;

class SomeTest extends TestCase
{
    use AssertEncrypted;

    /** @test */
    public function it_stores_users_secrets()
    {
        // Given
        $user = factory(User::class)->create([
            'secret' => encrypt('api-key')
        ]);

        // Then
        $this->assertEncrypted('users', ['id' => $user->id], [
            'secret' => 'api-key'
        ]);

        // assertEncrypted is an alias for assertEncryptedSerialized
        // since encrypt by default serializes the passed value
    }
}



 /** @test */
public function it_stores_users_secrets()
{
    // Given
    $user = factory(User::class)->create([
        'secret' => encrypt('api-key', false)
    ]);

    // Then
    $this->assertEncryptedUnserialized('users', ['id' => $user->id], [
        'secret' => 'api-key'
    ]);
}