Beispiel #1
0
 /**
  * @test
  */
 public function it_should_boot_callback_trait_and_register_observer()
 {
     $husband = am::double('Husband', ['observe' => null]);
     \Husband::bootCallableTrait();
     // $husband->verifyInvoked('observe');
 }
 /**
  * @test
  * @expectedException \BadMethodCallException
  */
 public function it_should_not_call_methods_on_the_proxy()
 {
     /**
      *
      * Expectation
      *
      */
     App::clearResolvedInstance('app');
     App::shouldReceive('make')->with('Elasticsearch')->andReturn(true);
     App::shouldReceive('make')->with('iverberk.larasearch.index', m::type('array'))->andReturn(true);
     /**
      *
      * Assertion
      *
      */
     // Overrule the proxy defined in previous tests
     am::double('Husband', ['getProxy' => new Proxy(new Husband())]);
     // Call a non existing method
     \Husband::bogus('*');
 }
 /**
  *
  */
 public function it_shoud_reindex_on_model_delete()
 {
     /**
      *
      * Expectation
      *
      */
     Facade::clearResolvedInstances();
     Queue::shouldReceive('push')->with('Iverberk\\Larasearch\\Jobs\\DeleteJob', ['Husband:2'])->once();
     Queue::shouldReceive('push')->with('Iverberk\\Larasearch\\Jobs\\ReindexJob', ['Wife:2', 'Child:2', 'Toy:2'])->once();
     Config::shouldReceive('get')->with('/^larasearch::reversedPaths\\..*$/', array())->once()->andReturn(['', 'wife', 'children', 'children.toys']);
     $husband = \Husband::find(2);
     with(new Observer())->deleted($husband);
 }
Beispiel #4
0
 /**
  * @test
  */
 public function it_should_reindex_on_model_delete()
 {
     /**
      *
      * Expectation
      *
      */
     Facade::clearResolvedInstances();
     Queue::shouldReceive('push')->with('Menthol\\Flexible\\Jobs\\DeleteJob', ['Husband:2'])->once();
     $config = m::mock('Menthol\\Flexible\\Config');
     App::shouldReceive('make')->with('Menthol\\Flexible\\Config')->andReturn($config);
     $config->shouldReceive('get')->with('/^reversedPaths\\..*$/', [])->once()->andReturn(['', 'wife', 'children', 'children.toys']);
     Queue::shouldReceive('push')->with('Menthol\\Flexible\\Jobs\\ReindexJob', ['Wife:2', 'Child:2', 'Toy:2'])->once();
     $husband = \Husband::find(2);
     with(new Observer())->deleted($husband);
 }