public function testUpdateOrderingRecordActionTemplate()
 {
     $actionTemplate = new UpdateOrderingRecordActionTemplate();
     $runner = new ActionRunner();
     $actionTemplate->register($runner, 'UpdateOrderingRecordActionTemplate', array('namespace' => 'OrderingTest', 'model' => 'Test2Model'));
     $className = 'OrderingTest\\Action\\UpdateTest2ModelOrdering';
     $this->assertCount(1, $runner->getPretreatments());
     $this->assertNotNull($pretreatment = $runner->getActionPretreatment($className));
     $generatedAction = $actionTemplate->generate($className, $pretreatment);
     $this->assertRequireGeneratedAction($className, $generatedAction);
 }
Ejemplo n.º 2
0
 public function testUpdateOrdering()
 {
     $idList = array();
     foreach (range(1, 20) as $num) {
         $product = $this->createProduct("Book {$num}");
         ok($product);
         $idList[] = ['record' => $product->id, 'ordering' => 21 - $num];
     }
     $products = new ProductCollection();
     $this->assertEquals(20, $products->count());
     $actionTemplate = new UpdateOrderingRecordActionTemplate();
     $runner = new ActionKit\ActionRunner();
     $actionTemplate->register($runner, 'UpdateOrderingRecordActionTemplate', array('namespace' => 'ProductBundle', 'model' => 'Product'));
     $className = 'ProductBundle\\Action\\UpdateProductOrdering';
     $this->assertNotNull($pretreatment = $runner->getActionPretreatment($className));
     $generatedAction = $actionTemplate->generate($className, $pretreatment['arguments']);
     $this->assertNotNull($generatedAction);
     $tmp = $generatedAction->load();
     $updateOrdering = new $className(array('list' => json_encode($idList)));
     is($updateOrdering->getName(), 'UpdateProductOrdering');
     ok($updateOrdering->run());
     $result = $updateOrdering->loadRecord(9);
     is($result->ordering, 21 - 9);
     $updateOrdering->mode = 99;
     is(false, $updateOrdering->run());
 }