Exemplo n.º 1
0
 /**
  * @test
  */
 public function it_should_reindex_on_model_save()
 {
     /**
      *
      * Expectation
      *
      */
     Facade::clearResolvedInstances();
     $proxy = m::mock('Iverberk\\Larasearch\\Proxy');
     $proxy->shouldReceive('shouldIndex')->andReturn(true);
     App::shouldReceive('make')->with('iverberk.larasearch.proxy', m::type('Illuminate\\Database\\Eloquent\\Model'))->andReturn($proxy);
     Config::shouldReceive('get')->with('/^larasearch::reversedPaths\\.Husband$/', array())->once()->andReturn(['', 'wife', 'children', 'children.toys']);
     Queue::shouldReceive('push')->with('Iverberk\\Larasearch\\Jobs\\ReindexJob', ['Husband:2', 'Wife:2', 'Child:2', 'Toy:2'])->once();
     /**
      *
      *
      * Assertion
      *
      */
     $husband = \Husband::find(2);
     with(new Observer())->saved($husband);
     /**
      *
      * Expectation
      *
      */
     Facade::clearResolvedInstances();
     $proxy = m::mock('Iverberk\\Larasearch\\Proxy');
     $proxy->shouldReceive('shouldIndex')->andReturn(true);
     App::shouldReceive('make')->with('iverberk.larasearch.proxy', m::type('Illuminate\\Database\\Eloquent\\Model'))->andReturn($proxy);
     Config::shouldReceive('get')->with('/^larasearch::reversedPaths\\.Toy$/', array())->once()->andReturn(['', 'children', 'children.mother.husband', 'children.mother']);
     Queue::shouldReceive('push')->with('Iverberk\\Larasearch\\Jobs\\ReindexJob', ['Toy:2', 'Child:8', 'Child:2', 'Husband:8', 'Husband:2', 'Wife:8', 'Wife:2'])->once();
     /**
      *
      *
      * Assertion
      *
      */
     $toy = \Toy::find(2);
     with(new Observer())->saved($toy);
 }
Exemplo n.º 2
0
 /**
  * @test
  */
 public function it_should_reindex_on_model_save()
 {
     /**
      *
      * Expectation
      *
      */
     Facade::clearResolvedInstances();
     $config = m::mock('Menthol\\Flexible\\Config');
     $proxy = m::mock('Menthol\\Flexible\\Proxy');
     $proxy->shouldReceive('shouldIndex')->andReturn(true);
     App::shouldReceive('make')->with('menthol.flexible.proxy', m::type('Illuminate\\Database\\Eloquent\\Model'))->andReturn($proxy);
     App::shouldReceive('make')->with('Menthol\\Flexible\\Config')->andReturn($config);
     $config->shouldReceive('get')->with('reversedPaths.Husband', [])->once()->andReturn(['', 'wife', 'children', 'children.toys']);
     Queue::shouldReceive('push')->with('Menthol\\Flexible\\Jobs\\ReindexJob', ['Husband:2', 'Wife:2', 'Child:2', 'Toy:2'])->once();
     /**
      *
      * Assertion
      *
      */
     $husband = \Husband::find(2);
     $husband->clearProxy();
     with(new Observer())->saved($husband);
     /**
      *
      * Expectation
      *
      */
     Facade::clearResolvedInstances();
     $config = m::mock('Menthol\\Flexible\\Config');
     $proxy = m::mock('Menthol\\Flexible\\Proxy');
     $proxy->shouldReceive('shouldIndex')->andReturn(true);
     App::shouldReceive('make')->with('menthol.flexible.proxy', m::type('Illuminate\\Database\\Eloquent\\Model'))->andReturn($proxy);
     App::shouldReceive('make')->with('Menthol\\Flexible\\Config')->andReturn($config);
     $config->shouldReceive('get')->with('reversedPaths.Toy', [])->once()->andReturn(['', 'children', 'children.mother.husband', 'children.mother']);
     Queue::shouldReceive('push')->with('Menthol\\Flexible\\Jobs\\ReindexJob', ['Toy:2', 'Child:8', 'Child:2', 'Husband:8', 'Husband:2', 'Wife:8', 'Wife:2'])->once();
     /**
      *
      * Assertion
      *
      */
     $toy = \Toy::find(2);
     with(new Observer())->saved($toy);
 }