/** * set up * * @return void */ public function setUp() { $session = m::mock('Illuminate\\Session\\SessionInterface'); $session->shouldReceive('get')->once()->andReturn(null); $session->shouldReceive('set')->once(); $this->session = $session; }
function __construct() { global $app_id; parent::__construct(); $this->table = 'eku'; $this->fields = array('eku_id', 'pid', 'pname', 'size', 'unit', 'num', 'customer', 'app_id', 'action_label', 'alert_level', 'kuwei', 'datetime', 'doer', 'remark', 'category', 'balance', 'cur_balance'); }
function __construct() { global $app_id; parent::__construct(); $this->table = 'bug_trace'; $this->fields = array('bugid', 'poster', 'doer', 'post_time', 'content', 'attached'); }
function __construct() { parent::__construct(); $this->table = 'user'; $this->fields = array('email', 'username', 'password', 'post_time', 'update_time', 'level', 'info'); $this->auth = 'auth'; $this->login_err = ''; }
function __construct() { global $app_id; parent::__construct(); $this->table = 'user_app'; $this->app = $app_id; $this->fields = array('app_id', 'user_id', 'join_time', 'app'); }
public function setUp() { parent::setUp(); $this->container = new Container(); $this->mysqlConnectionMock = m::mock('\\Fairy\\ConnectionAdapters\\Mysql'); $this->mysqlConnectionMock->shouldReceive('connect')->andReturn($this->mockPdo); $this->container->setInstance('\\Fairy\\ConnectionAdapters\\Mysqlmock', $this->mysqlConnectionMock); $this->connection = new Connection('mysqlMock', array('prefix' => 'cb_')); $this->connection->setPdoInstance($this->mockPdo); }
/** * test trash manager * * @return void */ public function testTrashManager() { $container = m::mock('Xpressengine\\Register\\Container'); $container->shouldReceive('add'); $container->shouldReceive('push'); $container->shouldReceive('set'); $container->shouldReceive('get')->andReturn([Waste::class]); $conn = m::mock('Xpressengine\\Database\\VirtualConnectionInterface'); $trash = new TrashManager($container, $conn); $trash->register(Waste::class); $this->assertEquals(1, count($trash->gets())); $this->assertEquals('test', $trash->names()[0]['name']); $trash->clean(); $trash->clean([Waste::class]); }
/** * test get type from counter name's configure * * @return void */ public function testType() { $configManager = $this->configManager; $configHandler = m::mock('Xpressengine\\Counter\\ConfigHandler', [$configManager])->shouldAllowMockingProtectedMethods()->makePartial(); $configEntity = $this->getConfigEntity(); $configEntity->shouldReceive('get')->once()->andReturn(null); $configHandler->shouldReceive('get')->andReturn($configEntity); $type = $configHandler->getType('id-counter'); $this->assertEquals(\Xpressengine\Counter\Counter::TYPE_ID, $type); // set config entity $configEntity->shouldReceive('get')->with('id-counter')->andReturn(\Xpressengine\Counter\Counter::TYPE_ID); $configEntity->shouldReceive('get')->with('session-counter')->andReturn(\Xpressengine\Counter\Counter::TYPE_SESSION); $configHandler->shouldReceive('get')->andReturn($configEntity); $type = $configHandler->getType('id-counter'); $this->assertEquals(\Xpressengine\Counter\Counter::TYPE_ID, $type); $type = $configHandler->getType('session-counter'); $this->assertEquals(\Xpressengine\Counter\Counter::TYPE_SESSION, $type); }
public function tearDown() { m::close(); }
/** * test put exception * * @expectedException \Xpressengine\Document\Exceptions\ConfigException * @return void */ public function testPutChangedInstanceIdException() { $instanceConfig1 = m::mock('Xpressengine\\Config\\ConfigEntity'); $instanceConfig1->shouldReceive('get')->with('instanceId')->andReturn('instance1'); $instanceConfig1->shouldReceive('diff')->andReturn(['instance1' => 'changed']); $configManager = m::mock('Xpressengine\\Config\\ConfigManager'); $configManager->shouldReceive('get')->andReturn(null); /** @var \Xpressengine\Config\ConfigManager $configManager */ $configHandler = new ConfigHandler($configManager); /** @var \Xpressengine\Config\ConfigEntity $instanceConfig1 */ $configHandler->put($instanceConfig1); }
/** * test fetch by user ids * * @return void */ public function testFetchByUserIds() { $conn = $this->conn; $query = $this->query; $repo = m::mock('Xpressengine\\Counter\\Repository', [$conn])->shouldAllowMockingProtectedMethods()->makePartial(); $repo->shouldReceive('wheres')->andReturn($query); $repo->shouldReceive('orders')->andReturn($query); $query->shouldReceive('wheres')->andReturn($query); $query->shouldReceive('take')->andReturn($query); $query->shouldReceive('lists')->andReturn(['userId']); $result = $repo->fetchByUserIds([], []); $this->assertEquals(['userId'], $result); $result = $repo->fetchByUserIds([], [], 10); $this->assertEquals(['userId'], $result); }
/** * test get users * * @return void */ public function testGetUsers() { $counterName = 'test'; $counter = $this->getCounter($counterName); $targetId = 'targetId'; $userId = 'userId'; $user = '******'; $counterLogModel = $this->getCounterLogModel(); $returnLogModel = m::mock('stdClass'); $returnLogModel->user = $user; $counterLogModel->shouldReceive('get')->andReturn([$returnLogModel]); $counterLogModel->shouldReceive('where')->once()->with('targetId', $targetId)->andReturnSelf(); $counterLogModel->shouldReceive('where')->once()->with('counterName', $counterName)->andReturnSelf(); $counterLogModel->shouldReceive('where')->once()->with('counterOption', '')->andReturnSelf(); $counter->shouldReceive('newModel')->andReturn($counterLogModel); $result = $counter->getUsers($targetId); $this->assertEquals($user, $result[0]); }
/** * @return M\MockInterface|\Xpressengine\Document\DocumentEntity */ private function getDocumentEntity() { return m::mock('Xpressengine\\Document\\DocumentEntity'); }
/** * test insert reply to parent not exist * * @expectedException \Xpressengine\Document\Exceptions\DocumentNotExistsException * @return void */ public function testInsertReplyParentNotExist() { $conn = $this->conn; $documentRepository = $this->documentRepository; $revisionRepository = $this->revisionRepository; $replyHelper = $this->replyHelper; /** @var M\MockInterface|\Xpressengine\Document\RepositoryHandler $repository */ $repository = m::mock('Xpressengine\\Document\\RepositoryHandler', [$conn, $documentRepository, $revisionRepository, $replyHelper])->shouldAllowMockingProtectedMethods()->makePartial(); $doc = $this->getDocumentEntity(); $doc->id = 'documentId'; $doc->instanceId = 'instanceId'; $doc->writer = 'writer'; $doc->parentId = 'parentId'; $config = $this->getConfigEntity(); $documentRepository->shouldReceive('insert')->andReturn($doc); // get parent $repository->shouldReceive('findById')->andReturn(null); $repository->insert($doc, $config); }
function __construct() { parent::__construct(); }
protected function getMockQueryBuilder() { $query = m::mock('Vinelab\\NeoEloquent\\Query\\Builder'); $query->shouldReceive('from')->with('foo_table'); $query->shouldReceive('modelAsNode')->andReturn('n'); return $query; }
/** * get config entity * * @return M\MockInterface|\Xpressengine\Config\ConfigEntity */ private function getConfigEntity() { return m::mock('Xpressengine\\Config\\ConfigEntity'); }
public function setupCacheTestQuery($cache, $driver) { $connection = m::mock('Vinelab\\NeoEloquent\\Connection'); $connection->shouldReceive('getClient')->once()->andReturn(M::mock('Everyman\\Neo4j\\Client')); $connection->shouldReceive('getName')->andReturn('default'); $connection->shouldReceive('getCacheManager')->once()->andReturn($cache); $cache->shouldReceive('driver')->once()->andReturn($driver); $grammar = new CypherGrammar(); $builder = $this->getMock('Vinelab\\NeoEloquent\\Query\\Builder', array('getFresh'), array($connection, $grammar)); $builder->expects($this->once())->method('getFresh')->with($this->equalTo(array('*')))->will($this->returnValue(array('results'))); return $builder->select('*')->from('User')->where('email', '*****@*****.**'); }
/** * Repository helper interface test * * @return void */ public function testForRepositoryInterface() { $repo = $this->repo; $session = $this->session; $configHandler = $this->configHandler; $member = $this->member; $auth = $this->auth; $request = $this->request; $counter = m::mock('Xpressengine\\Counter\\Counter', [$repo, $session, $configHandler, $member, $auth, $request])->shouldAllowMockingProtectedMethods()->makePartial(); // get users $repo->shouldReceive('fetchByUserIds')->andReturn(['userId']); $member->shouldReceive('find')->andReturn(['user1' => 'userId']); $result = $counter->getUsers('targetId'); $this->assertEquals(['user1' => 'userId'], $result[0]); $result = $counter->getUserIds('targetId'); $this->assertEquals(['userId'], $result); }
/** * get connnection * * @return \Illuminate\Database\Connection */ private function getConnection() { $connection = m::mock('Illuminate\\Database\\Connection'); return $connection; }
<?php class m extends Mongo { function __construct() { } } try { $m = new m(); $m->connect(); } catch (Exception $e) { var_dump($e->getMessage()); } ?> ===DONE===
/** * test permission * * @return void */ public function testPermission() { $entity = new DocumentEntity(); $entity->setUserType(DocumentEntity::USER_TYPE_GUEST); $guest = m::mock('Xpressengine\\Member\\Entities\\Guest'); $guest->shouldReceive('getId')->andReturn('guest'); $guest->shouldReceive('getDisplayName')->andReturn('guest'); $this->assertTrue($entity->alterPerm($guest)); $this->assertTrue($entity->deletePerm($guest)); $entity->setUserType(DocumentEntity::USER_TYPE_USER); $entity->userId = 'id'; $this->assertFalse($entity->alterPerm($guest)); $this->assertFalse($entity->deletePerm($guest)); $user = m::mock('Xpressengine\\Member\\Entities\\Database\\MemberEntity'); $user->shouldReceive('getId')->andReturn('id'); $user->shouldReceive('getDisplayName')->andReturn('name'); $author = m::mock('Xpressengine\\Member\\Entities\\Database\\MemberEntity'); $author->shouldReceive('getId')->andReturn('id_author'); $author->shouldReceive('getDisplayName')->andReturn('name_author'); $entity->setAuthor($user); $this->assertFalse($entity->alterPerm($author)); $this->assertFalse($entity->deletePerm($author)); $this->assertTrue($entity->alterPerm($user)); $this->assertTrue($entity->deletePerm($user)); }
public function testPersist() { // Zend\Db\Adapter\Driver\ResultInterface $resultInterface = m::mock('Zend\\Db\\Adapter\\Driver\\ResultInterface'); $resultInterface->shouldReceive('rewind')->withNoArgs()->once(); $resultInterface->shouldReceive('valid')->withNoArgs()->times(1)->andReturn(1); $resultInterface->shouldReceive('current')->withNoArgs()->times(1); $resultInterface->shouldReceive('next')->withNoArgs()->times(1)->andReturn('Foo'); $resultInterface->shouldReceive('valid')->withNoArgs()->times(1)->andReturn(0); $this->statement->shouldReceive('execute')->once()->andReturn($resultInterface); $profile = Profile::create(); $this->assertSame($this->handler, $this->handler->persist($profile)); }
public function testRollBackedFiresEventsIfSet() { $connection = $this->getMockConnection(array('getName')); $connection->expects($this->once())->method('getName')->will($this->returnValue('name')); $connection->setEventDispatcher($events = m::mock('Illuminate\\Events\\Dispatcher')); $events->shouldReceive('fire')->once()->with('connection.name.rollingBack', $connection); $connection->rollBack(); }
/** * test fetch by id * * @return void */ public function testFetchById() { $conn = $this->conn; $revisionManager = $this->revisionManager; $keygen = $this->keygen; $repo = m::mock('Xpressengine\\Document\\Repositories\\RevisionRepository', [$conn, $revisionManager, $keygen])->shouldAllowMockingProtectedMethods()->makePartial(); $id = 'documentId'; $revisionId = 'revisionId'; $config = $this->getConfigEntity(); $config->shouldReceive('get')->with('group')->andReturn('document-instanceId'); $query = $this->query; $query->shouldReceive('getQuery')->andReturn(m::mock('Illuminate\\Database\\Query\\Builder')); $query->shouldReceive('where')->andReturn($query); $query->shouldReceive('orderBy')->andReturn($query); $query->shouldReceive('get')->andReturn([['id' => $id, 'revisionId' => $revisionId]]); $revisionManager->shouldReceive('join')->andReturn($query); $revisionManager->shouldReceive('getHandler')->andReturn($dynamicFieldHandler = m::mock('Xpressengine\\DynamicField\\DynamicFieldHandler')); $dynamicFieldHandler->shouldReceive('getConfigHandler')->andReturn($dfConfigHandler = m::mock('Xpressengine\\DynamicField\\ConfigHandler')); $dfConfigHandler->shouldReceive('gets')->andReturn([]); $result = $repo->fetchById($id, $config); $this->assertEquals($id, $result[0]['id']); }