コード例 #1
0
 /**
  * Simple test that will test if the immutable object is created as wished
  */
 public function testBasicColumnConfiguration()
 {
     $name = "fooBar";
     $cc = ColumnConfigurationBuilder::create()->name($name)->searchable(Searchable::REGEX())->orderable(Orderable::NONE())->build();
     $this->assertSame($name, $cc->getName(), "Name should be set correctly");
     $this->assertTrue($cc->getSearch()->isSearchable(), "The column should be searchable");
     $this->assertFalse($cc->getOrder()->isOrderable(), "The column should be orderable");
 }
コード例 #2
0
 /**
  * Will test if the query parser will ignore search and order advise if the columns forbid them
  *
  */
 public function testWrongParsing()
 {
     // create columnconfiguration
     $column = ColumnConfigurationBuilder::create()->name("fooBar")->orderable(Orderable::NONE())->searchable(Searchable::NONE())->build();
     $conf = $this->parser->parse($this->request, [$column]);
     // assert column search
     $this->assertCount(0, $conf->searchColumns());
     // assert column order
     $this->assertCount(0, $conf->orderColumns());
 }
コード例 #3
0
 /**
  * @expectedException OpenSkill\Datatable\DatatableException
  * @expectedExceptionMessage An unsupported DefaultSearchable was provided.
  */
 public function testDefaultOrderWithSearchNotImplemented()
 {
     $this->orderAndSearchNotImplementedTest(Searchable::NOTIMPLEMENTED());
 }
コード例 #4
0
 /**
  * Will check if the searchable flag is correctly set, if not it will be set to the default NONE
  */
 private function checkSearchable()
 {
     if ($this->searchable == null) {
         $this->searchable = Searchable::NORMAL();
     }
 }
コード例 #5
0
 /**
  * Will check if the column method with the name and a callable as well as the searchable and orderable flag has
  * all values set to the right defaults
  */
 public function testNameFunctionSearchableOrderableColumn()
 {
     $name = "fooBar";
     $callable = function ($data) {
         return "bar";
     };
     $this->composer->column($name, $callable, Searchable::NONE(), Orderable::NONE());
     // get configuration and verify
     $numberOfColumns = count($this->composer->getColumnConfiguration());
     $this->assertSame($numberOfColumns, 1, "There should only be one column configuration");
     /**
      * @var ColumnConfiguration
      */
     $cc = $this->composer->getColumnConfiguration()[0];
     /**
      * @var callable
      */
     $func = $cc->getCallable();
     $this->assertTrue($cc->getSearch()->isSearchable(), "The column should not be searchable");
     $this->assertTrue($cc->getOrder()->isOrderable(), "The column should be orderable");
     $this->assertSame($name, $cc->getName(), "The name should be set to 'fooBar'");
     $this->assertSame("bar", $func("fooBar"));
 }
コード例 #6
0
 /**
  * Will create a new ColumnConfiguration with all defaults but allows overriding of all properties through the method.
  *
  * @param string $name The name of the configuration, required for the configuration
  * @param string|callable $callable The function to execute, defaults to null which means the default will be set.
  * @param Searchable $searchable If the column should be searchable or not
  * @param Orderable $orderable If the column should be orderable or not
  * @return $this
  */
 public function column($name, $callable = null, Searchable $searchable = null, Orderable $orderable = null)
 {
     /**
      * @var ColumnConfigurationBuilder
      */
     $config = ColumnConfigurationBuilder::create();
     if (is_string($name)) {
         $config->name($name);
     } else {
         throw new \InvalidArgumentException('$name must be a string');
     }
     if (!is_null($callable)) {
         if (is_callable($callable)) {
             $config->withCallable($callable);
         } elseif (is_string($callable)) {
             $config->withCallable(function () use($callable) {
                 return $callable;
             });
         }
     }
     if (is_null($searchable)) {
         $config->searchable(Searchable::NORMAL());
     }
     if (is_null($orderable)) {
         $config->orderable(Orderable::BOTH());
     }
     $this->columnConfiguration[] = $config->build();
     return $this;
 }
コード例 #7
0
 /**
  * Will test that the global search respects individual column settings
  */
 public function testGlobalSearchWithIndividualColumn()
 {
     $data = [['id' => 1, 'name' => 'foo'], ['id' => 2, 'name' => 'bar']];
     $queryConfiguration = QueryConfigurationBuilder::create()->start(0)->length(2)->searchValue('foo')->drawCall(1)->build();
     $columnConfiguration = ColumnConfigurationBuilder::create()->name('id')->build();
     $columnConfiguration2 = ColumnConfigurationBuilder::create()->name('name')->searchable(Searchable::NONE())->build();
     $provider = new CollectionProvider(new Collection($data));
     $provider->prepareForProcessing($queryConfiguration, [$columnConfiguration, $columnConfiguration2]);
     $data = $provider->process();
     $this->assertSame(0, $data->data()->count());
 }
コード例 #8
0
 public function testClass()
 {
     $t = Searchable::REGEX();
     $this->assertTrue($t->isSearchable());
 }
コード例 #9
0
 public function testClass()
 {
     $t = Searchable::NONE();
     $this->assertFalse($t->isSearchable());
 }
コード例 #10
0
 public function testClass()
 {
     $t = Searchable::NOTIMPLEMENTED();
     $this->assertTrue($t->isSearchable());
 }