11<?php namespace NumenCode \Widgets \Tests \Components ;
22
3- use Mockery ;
43use PluginTestCase ;
54use NumenCode \Widgets \Components \Gallery ;
65use NumenCode \Widgets \Models \GalleryGroup ;
6+ use Mockery ;
77
88class GalleryTest extends PluginTestCase
99{
@@ -23,10 +23,12 @@ public function testComponentInitialization(): void
2323 $ properties = $ component ->defineProperties ();
2424 $ this ->assertArrayHasKey ('title ' , $ properties );
2525 $ this ->assertArrayHasKey ('layout ' , $ properties );
26+ $ this ->assertArrayHasKey ('items_per_row ' , $ properties );
2627
2728 // Check default values
2829 $ this ->assertEquals ('default ' , $ properties ['title ' ]['default ' ]);
2930 $ this ->assertEquals ('default ' , $ properties ['layout ' ]['default ' ]);
31+ $ this ->assertEquals ('4 ' , $ properties ['items_per_row ' ]['default ' ]);
3032 }
3133
3234 /**
@@ -59,31 +61,29 @@ public function testGetLayoutOptions(): void
5961
6062 $ layoutOptions = $ component ->getLayoutOptions ();
6163 $ this ->assertArrayHasKey ('default ' , $ layoutOptions );
62- $ this ->assertArrayHasKey ('media ' , $ layoutOptions );
6364 $ this ->assertEquals ('Default ' , $ layoutOptions ['default ' ]);
64- $ this ->assertEquals ('Default with pictures ' , $ layoutOptions ['media ' ]);
6565 }
6666
6767 /**
68- * Test the onRun method loads the correct group .
68+ * Test the onRun method loads the correct gallery .
6969 */
70- public function testOnRunLoadsGroup (): void
70+ public function testOnRunLoadsGallery (): void
7171 {
72- // Mock GalleryGroup::find to return a dummy group
72+ // Mock GalleryGroup::find to return a dummy gallery
7373 $ mock = Mockery::mock ('alias: ' . GalleryGroup::class);
7474 $ mock ->shouldReceive ('find ' )->with (1 )->once ()->andReturn ([
7575 'id ' => 1 ,
76- 'title ' => 'Sample Group ' ,
76+ 'title ' => 'Sample Gallery ' ,
7777 ]);
7878
7979 $ component = new Gallery ();
8080 $ component ->setProperty ('title ' , 1 );
8181
8282 $ component ->onRun ();
8383
84- $ this ->assertIsArray ($ component ->group );
85- $ this ->assertEquals (1 , $ component ->group ['id ' ]);
86- $ this ->assertEquals ('Sample Group ' , $ component ->group ['title ' ]);
84+ $ this ->assertIsArray ($ component ->gallery );
85+ $ this ->assertEquals (1 , $ component ->gallery ['id ' ]);
86+ $ this ->assertEquals ('Sample Gallery ' , $ component ->gallery ['title ' ]);
8787 }
8888
8989 /**
@@ -95,13 +95,13 @@ public function testOnRenderSelectsCorrectLayout(): void
9595
9696 // Mock renderPartial to check the rendered layout
9797 $ component ->shouldReceive ('renderPartial ' )
98- ->with ('@media .htm ' )
99- ->andReturn ('Rendered Media Layout ' );
98+ ->with ('@custom .htm ' )
99+ ->andReturn ('Rendered Custom Layout ' );
100100
101- $ component ->setProperty ('layout ' , 'media ' );
101+ $ component ->setProperty ('layout ' , 'custom ' );
102102
103103 $ output = $ component ->onRender ();
104- $ this ->assertEquals ('Rendered Media Layout ' , $ output );
104+ $ this ->assertEquals ('Rendered Custom Layout ' , $ output );
105105 }
106106
107107 /**
0 commit comments