Skip to content
Snippets Groups Projects
Commit dfa4e81e authored by dyszczo's avatar dyszczo
Browse files

integration storage test

parent 2109111b
No related branches found
No related tags found
1 merge request!25Feature/storage test
Pipeline #8528 passed
......@@ -17,7 +17,7 @@ class WordpressFilterStorage implements PluginStorage {
* @param AbstractPlugin $object
*/
public function add_to_storage( $class, $object ) {
add_filter( self::STORAGE_FILTER_NAME, function ( $plugins ) use ( $class, $object ) {
add_filter( self::STORAGE_FILTER_NAME, static function ( $plugins ) use ( $class, $object ) {
if ( isset( $plugins[ $class ] ) ) {
throw new Exception\ClassAlreadyExists( "Class {$class} already exists" );
}
......
<?php
use WPDesk\Plugin\Flow\Initialization\Simple\SimpleStrategy;
use WPDesk\PluginBuilder\Storage\Exception\ClassNotExists;
use WPDesk\PluginBuilder\Storage\WordpressFilterStorage;
class Test_WordpressFilterStorage extends WP_UnitTestCase {
public function test_can_read_and_write() {
$storage = new WordpressFilterStorage();
$storage->add_to_storage( Test_WordpressFilterStorage::class, $this );
$this->assertInstanceOf( Test_WordpressFilterStorage::class,
$storage->get_from_storage( Test_WordpressFilterStorage::class ),
'Returned instance should be the same as saved' );
}
public function test_empty_storage_is_empty() {
$storage = new WordpressFilterStorage();
$this->expectException( ClassNotExists::class );
$storage->get_from_storage( Test_WordpressFilterStorage::class );
}
}
......@@ -18,7 +18,6 @@ if ( getenv( 'PLUGIN_PATH' ) !== false ) {
require_once( getenv( 'WP_DEVELOP_DIR' ) . '/tests/phpunit/includes/functions.php' );
tests_add_filter( 'muplugins_loaded', function () {
$plugins_to_active[] = 'hello.php';
update_option( 'active_plugins', $plugins_to_active );
}, 100 );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment