diff --git a/src/Plugin/Block/InstagramBlockBlock.php b/src/Plugin/Block/InstagramBlockBlock.php index b75e543..d21b3a7 100644 --- a/src/Plugin/Block/InstagramBlockBlock.php +++ b/src/Plugin/Block/InstagramBlockBlock.php @@ -76,6 +76,7 @@ class InstagramBlockBlock extends BlockBase implements ContainerFactoryPluginInt */ public function defaultConfiguration() { return [ + 'user_id' => '', 'count' => 4, 'width' => 150, 'height' => 150, diff --git a/src/Tests/InstagramBlockPlaceBlockTest.php b/src/Tests/InstagramBlockPlaceBlockTest.php index bc446ac..bb777e8 100644 --- a/src/Tests/InstagramBlockPlaceBlockTest.php +++ b/src/Tests/InstagramBlockPlaceBlockTest.php @@ -76,6 +76,7 @@ class InstagramBlockPlaceBlockTest extends WebTestBase { // Test context mapping with valid data. $this->drupalGet('admin/structure/block/manage/instagramblock'); $edit = [ + 'settings[user_id]' => '412345678', 'settings[count]' => '4', 'settings[width]' => '150', 'settings[height]' => '150', @@ -85,26 +86,33 @@ class InstagramBlockPlaceBlockTest extends WebTestBase { $this->drupalPostForm(NULL, $edit, 'Save block'); $this->assertText('The block configuration has been saved.', 'Block save without errors.'); + // Test user_id with invalid data. + $edit = [ + 'settings[user_id]' => $this->randomString(9), + ]; + $this->drupalPostForm('admin/structure/block/manage/instagramblock', $edit, 'Save block'); + $this->assertText('User id must be a number.', 'Block failed to save.'); + // Test count with invalid data. $edit = [ 'settings[count]' => $this->randomString(4), ]; $this->drupalPostForm('admin/structure/block/manage/instagramblock', $edit, 'Save block'); - $this->assertText('Number of images to display. must be a number.', 'Block failed to save.'); + $this->assertText('Number of images to display must be a number.', 'Block failed to save.'); // Test width with invalid data. $edit = [ 'settings[width]' => $this->randomString(4), ]; $this->drupalPostForm('admin/structure/block/manage/instagramblock', $edit, 'Save block'); - $this->assertText('Image width in pixels. must be a number.', 'Block failed to save.'); + $this->assertText('Image width in pixels must be a number.', 'Block failed to save.'); // Test height with invalid data. $edit = [ 'settings[height]' => $this->randomString(4), ]; $this->drupalPostForm('admin/structure/block/manage/instagramblock', $edit, 'Save block'); - $this->assertText('Image height in pixels. must be a number.', 'Block failed to save.'); + $this->assertText('Image height in pixels must be a number.', 'Block failed to save.'); // Test cache_time_minutes with invalid data. $edit = [