Пример #1
0
 public function testUsage()
 {
     /*
      * Komponenty
      * SearchManager
      *    SearchForm
      *    SearchResult
      *    SearchSettings
      */
     //Defines props. Components has to decide, if it will use it (default)
     //or will use their oru value
     $dependency1 = new Dependency1();
     $dependency2 = new Dependency2();
     $propsSearchManager = new Props(['searchForm.PlaceHolder' => 'Default placeholder', 'searchResult.ActiveColor' => '#red', 'searchSettings.ShowGlobal' => false, 'dependency1' => $dependency1, 'dependency2' => $dependency2, 'renderMethod' => function () {
         echo "Hello world";
     }]);
     //$control = new SearchManagerControl($propsSearchManager)
     //In search manager, who builds 3 components, search manager creates
     //
     // in SearchManager, creating SearchForm
     $searchFormProps = $propsSearchManager->create(['searchForm.PlaceHolder']);
     $searchFormProps->{"searchForm.ShowDescription"} = true;
     $searchControl = new SearchManagerControl($propsSearchManager);
     $searchControl['search'];
     $this->assertSame($dependency1, $searchControl->dep);
 }
Пример #2
0
 public function testCall()
 {
     $props = new Props();
     $props->callme = function ($a, $b) {
         //dump($this);
         return $a + $b;
     };
     $this->assertEquals(5, $props->callme(2, 3));
 }
Пример #3
0
 /**
  * @param $key
  * @param bool $display
  * @return array|bool|int|string
  * @deprecated
  */
 function _get($key, $display = false)
 {
     return $this->props->get($key, $display);
 }