Beispiel #1
0
 function it_deleteSearchIndex(ZendSearchManager $zendsearch)
 {
     $zendsearch_ptr = function () use($zendsearch) {
         $str = Argument::type('string');
         $zendsearch->delete($str)->shouldBeCalled()->willReturn(null);
         return $zendsearch->getWrappedObject();
     };
     DICService::update('zend_search', $zendsearch_ptr);
     $this->deleteSearchIndex(1);
     DICService::delete('zend_search');
 }
Beispiel #2
0
 function it_render(EngineManager $engine)
 {
     $engine_ptr = function () use($engine) {
         $engine->render($this->getWrappedObject(), 'index', [])->will(function () {
             echo '123456 TEST A';
             return true;
         })->shouldBeCalled();
         return $engine->getWrappedObject();
     };
     DICService::update('render', $engine_ptr);
     $this->render('index')->shouldBe('123456 TEST A');
 }
Beispiel #3
0
 public function test()
 {
     $func = function () {
         $manager = $this->getMock('BX\\Logger\\LoggerManager', ['setHandler']);
         $manager->expects($this->once())->method('setHandler')->will($this->returnCallback(function ($logger) {
             $handler = $this->getMockForAbstractClass('Monolog\\Handler\\AbstractProcessingHandler');
             $handler->expects($this->once())->method('write');
             $logger->pushHandler($handler);
         }));
         return $manager;
     };
     DICService::update('logger', $func);
     $this->log()->warn('12345');
 }
Beispiel #4
0
 function it_find(DatabaseManager $db)
 {
     $return = ['ID' => 1, 'TEST' => 'TEST'];
     $result = new DBResult($return);
     $db_ptr = function () use($db, $result) {
         $db->esc(Argument::any(), Argument::any())->willReturnArgument();
         $sql = 'SELECT T.ID as ID,T.TEST as TEST FROM tbl_test T ' . 'WHERE T.TEST = :test_0 AND T.TEST = :test ' . 'GROUP BY T.ID ' . 'ORDER BY T.ID DESC';
         $params = ['test_0' => 'TEST', 'test' => 'TEST2'];
         $db->query($sql, $params)->shouldBeCalled()->willReturn($result);
         return $db->getWrappedObject();
     };
     DICService::update('db', $db_ptr);
     $this->filter(['=TEST' => 'TEST'])->select('ID', 'TEST')->sort(['ID' => 'desc'])->group('ID')->where('T.TEST = :test', ['test' => 'TEST2'])->find()->shouldBe($result);
 }
Beispiel #5
0
 function it_load(Sqlite $adaptor)
 {
     $adaptor_ptr = function () use($adaptor) {
         $adaptor->resetAI('tbl_test')->shouldBeCalled();
         $adaptor->getLastId()->willReturn(5);
         $pdo = new Sqlite();
         $adaptor->pdo()->willReturn($pdo->pdo());
         $adaptor->getQuoteChar()->willReturn('`');
         $adaptor->execute('DELETE FROM `tbl_test` WHERE 1=1', [])->shouldBeCalled()->willReturn(true);
         $adaptor->execute('INSERT INTO `tbl_test`(`TEST`) VALUES(:test)', ['test' => 'TEST'])->shouldBeCalled()->willReturn(true);
         return $adaptor->getWrappedObject();
     };
     DICService::update('db_adaptor', $adaptor_ptr);
     $schema = ['tbl_test' => ['TEST' => 'TEST']];
     $this->load($schema)->shouldBe(true);
 }
Beispiel #6
0
 function it_validateAndAfter(EventManager $event, ZendSearchManager $zendsearch, CacheManager $cache)
 {
     $zendsearch->delete(Argument::any())->shouldBeCalled();
     $event->fire('OnBeforeTestDelete', Argument::any(), true)->shouldBeCalled()->willReturn(true);
     $event->fire('OnAfterTestDelete', Argument::any(), true)->shouldBeCalled()->willReturn(true);
     $cache->clearByTags('test')->shouldBeCalled()->willReturn(null);
     DICService::update('cache', function () use($cache) {
         return $cache->getWrappedObject();
     });
     DICService::update('zend_search', function () use($zendsearch) {
         return $zendsearch->getWrappedObject();
     });
     DICService::update('event', function () use($event) {
         return $event->getWrappedObject();
     });
     $this->validate();
     $this->onAfterCommit();
     DICService::delete('event');
     DICService::delete('zend_search');
     DICService::delete('cache');
 }