• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP test_spot_mapper函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中test_spot_mapper函数的典型用法代码示例。如果您正苦于以下问题:PHP test_spot_mapper函数的具体用法?PHP test_spot_mapper怎么用?PHP test_spot_mapper使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了test_spot_mapper函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: testSampleNewsDelete

 public function testSampleNewsDelete()
 {
     $mapper = test_spot_mapper();
     $post = $mapper->first('Entity_Post', array('title' => "Test Post Modified"));
     $result = $mapper->delete($post);
     $this->assertTrue($result);
 }
开发者ID:helix,项目名称:spot2,代码行数:7,代码来源:CRUD.php


示例2: testGetCustomEntityMapper

 public function testGetCustomEntityMapper()
 {
     $mapper = test_spot_mapper('SpotTest\\Entity\\Event');
     $this->assertInstanceOf(Entity\Event::mapper(), $mapper);
     $query = $mapper->testQuery();
     $this->assertInstanceOf('Spot\\Query', $query);
 }
开发者ID:GasimGasimzada,项目名称:spot2,代码行数:7,代码来源:Mapper.php


示例3: testLength

 public function testLength()
 {
     $mapper = test_spot_mapper();
     $entity = new Entity_Author(array('email' => 't@t', 'password' => 'test'));
     $mapper->save($entity);
     $this->assertTrue($entity->hasErrors());
     $this->assertContains("Email must be longer than 4", $entity->errors('email'));
 }
开发者ID:vlucas,项目名称:spot,代码行数:8,代码来源:Validation.php


示例4: testPostHasManyPolymorphicComments

 public function testPostHasManyPolymorphicComments()
 {
     $mapper = test_spot_mapper('SpotTest\\Entity\\Post');
     $post = $mapper->first();
     $this->assertInstanceOf('SpotTest\\Entity\\Post', $post);
     $query = $post->polymorphic_comments->query();
     $this->assertEquals(3, count($post->polymorphic_comments));
 }
开发者ID:GasimGasimzada,项目名称:spot2,代码行数:8,代码来源:RelationsPolymorphic.php


示例5: testLength

 public function testLength()
 {
     $mapper = test_spot_mapper('SpotTest\\Entity\\Author');
     $entity = new SpotTest\Entity\Author(['email' => 't@t', 'password' => 'test']);
     $mapper->save($entity);
     $this->assertTrue($entity->hasErrors());
     $this->assertContains("Email must be longer than 4", $entity->errors('email'));
 }
开发者ID:scottstamp,项目名称:BadgeScanner,代码行数:8,代码来源:Validation.php


示例6: testInsertPostArray

 public function testInsertPostArray()
 {
     $mapper = test_spot_mapper();
     $post = array('title' => "Test Post", 'body' => "<p>This is a really awesome super-duper post.</p><p>It's really quite lovely.</p>", 'date_created' => $mapper->connection('\\Spot\\Entity\\Post')->dateTime());
     $result = $mapper->insert('\\Spot\\Entity\\Post', $post);
     // returns inserted id
     $this->assertTrue($result !== false);
 }
开发者ID:brandonlamb,项目名称:spot,代码行数:8,代码来源:Insert.php


示例7: testEntitySetDataConstruct

 public function testEntitySetDataConstruct()
 {
     $mapper = test_spot_mapper();
     $post = new Entity_Post(array('title' => 'My Awesome Post', 'body' => '<p>Body</p>'));
     $data = $post->data();
     ksort($data);
     $testData = array('id' => null, 'title' => 'My Awesome Post', 'body' => '<p>Body</p>', 'status' => 0, 'date_created' => null);
     ksort($testData);
     $this->assertEquals($testData, $data);
 }
开发者ID:acidline,项目名称:rocket,代码行数:10,代码来源:Entity.php


示例8: testUniqueCompoundIndexNoValidationErrorWhenDataDifferent

 public function testUniqueCompoundIndexNoValidationErrorWhenDataDifferent()
 {
     $zipMapper = test_spot_mapper('\\SpotTest\\Entity\\Zip');
     $data = ['code' => '23456', 'city' => 'Testville', 'state' => 'NY', 'lat' => 1, 'lng' => 2];
     $zip1 = $zipMapper->create($data);
     // Make data slightly different on unique compound index
     $data2 = array_merge($data, ['city' => 'Testville2']);
     $zip2 = $zipMapper->create($data2);
     $this->assertEmpty($zip1->errors());
     $this->assertEmpty($zip2->errors());
 }
开发者ID:Rambomst,项目名称:spot2,代码行数:11,代码来源:Indexes.php


示例9: testEntityRelations

 public function testEntityRelations()
 {
     $mapper = test_spot_mapper();
     $post = new Entity_Post();
     $relations = $mapper->relations('Entity_Post');
     $sortedRelations = array_keys($relations);
     sort($sortedRelations);
     // Assert $relations are correct
     $testRelations = array('comments', 'tags', 'author');
     sort($testRelations);
     $this->assertEquals($sortedRelations, $testRelations);
 }
开发者ID:vlucas,项目名称:spot,代码行数:12,代码来源:Manager.php


示例10: testEntitySetPropertiesData

 public function testEntitySetPropertiesData()
 {
     $mapper = test_spot_mapper();
     $post = new Entity_Post();
     // Set data
     $post->title = "My Awesome Post";
     $post->body = "<p>Body</p>";
     $data = $mapper->data($post);
     ksort($data);
     $testData = array('id' => null, 'title' => 'My Awesome Post', 'body' => '<p>Body</p>', 'status' => null, 'date_created' => null);
     ksort($testData);
     $this->assertEquals($testData, $data);
 }
开发者ID:helix,项目名称:spot2,代码行数:13,代码来源:Entity.php


示例11: events

 public static function events(EventEmitter $eventEmitter)
 {
     $eventEmitter->on('beforeInsert', function ($entity, $mapper) {
         $entity->token = uniqid();
     });
     $eventEmitter->on('afterInsert', function ($entity, $mapper) {
         $mapper = test_spot_mapper('SpotTest\\Entity\\Event\\Search');
         $result = $mapper->create(['event_id' => $entity->id, 'body' => $entity->title . ' ' . $entity->description]);
         if (!$result) {
             throw new \Spot\Exception("Event search index entity failed to save!");
         }
     });
 }
开发者ID:scottstamp,项目名称:BadgeScanner,代码行数:13,代码来源:Event.php


示例12: testUniqueFieldCreatesValidationError

 public function testUniqueFieldCreatesValidationError()
 {
     $mapper = test_spot_mapper();
     // Setup new user
     $user1 = new \Spot\Entity\User(array('email' => '[email protected]', 'password' => 'test', 'is_admin' => true));
     $mapper->save($user1);
     // Setup new user (identical, expecting a validation error)
     $user2 = new \Spot\Entity\User(array('email' => '[email protected]', 'password' => 'test', 'is_admin' => false));
     $mapper->save($user2);
     $this->assertFalse($user1->hasErrors());
     $this->assertTrue($user2->hasErrors());
     $this->assertEquals($user2->errors('email'), array("Email '[email protected]' is already taken."));
 }
开发者ID:brandonlamb,项目名称:spot,代码行数:13,代码来源:Validation.php


示例13: testEventSearchIndex

 public function testEventSearchIndex()
 {
     $mapper = test_spot_mapper();
     if (!$mapper->config()->connection() instanceof \Spot\Adapter\Mysql) {
         $this->markTestSkipped('Only supported in MySQL - requires FULLTEXT search');
     }
     $event = new Entity_Event(array('title' => 'Test Event 1', 'description' => 'Test Description', 'type' => 'free', 'date_start' => strtotime('+1 day')));
     $mapper->save($event);
     // Ensure Event_Search record was inserted with 'afterSave' hook
     $eventSearchEntity = $mapper->first('Entity_Event_Search', array('event_id' => $event->id));
     $this->assertInstanceOf('Entity_Event_Search', $eventSearchEntity);
     $events = $mapper->all('Entity_Event_Search')->search('body', 'Test', array('boolean' => true))->execute();
     $this->assertGreaterThan(0, count($events));
 }
开发者ID:vlucas,项目名称:spot,代码行数:14,代码来源:Search.php


示例14: testRelationConditions

 public function testRelationConditions()
 {
     $mapper = test_spot_mapper();
     for ($i = 1; $i <= 10; $i++) {
         $id = $mapper->insert('Entity_Post', array('title' => ($i % 2 ? 'odd' : 'even') . '_title', 'author_id' => 1, 'body' => '<p>' . $i . '_body</p>', 'status' => $i, 'date_created' => $mapper->connection('Entity_Post')->dateTime()));
         for ($j = 1; $j <= 2; $j++) {
             $mapper->insert('Entity_Post_Comment', array('post_id' => $id, 'name' => ($j % 2 ? 'odd' : 'even') . '_title', 'email' => '[email protected]', 'body' => ($j % 2 ? 'odd' : 'even') . '_comment_body'));
         }
     }
     $post = $mapper->all('Entity_Post')->first();
     $relation = $mapper->loadRelation($post, 'comments');
     $this->assertEquals($relation->conditions(), array('post_id' => 1));
     $posts = $mapper->all('Entity_Post')->execute();
     $relation = $mapper->loadRelation($posts, 'comments');
     $this->assertEquals($relation->conditions(), array('post_id' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)));
 }
开发者ID:vlucas,项目名称:spot,代码行数:16,代码来源:Mapper.php


示例15: testInsertWithTransactionRollbackOnReturnFalse

 public function testInsertWithTransactionRollbackOnReturnFalse()
 {
     $post = new \Spot\Entity\Post();
     $mapper = test_spot_mapper();
     $post->title = "Rolledback";
     $post->body = "<p>This is a really awesome super-duper post -- in a TRANSACTION!.</p>";
     $post->date_created = $mapper->connection('\\Spot\\Entity\\Post')->dateTime();
     // Save in transation
     $phpunit = $this;
     $mapper->transaction(function ($mapper) use($post, $phpunit) {
         $result = $mapper->insert($post);
         // Return false AFTER save to trigger rollback
         return false;
     });
     // Ensure record was NOT saved
     $this->assertFalse($mapper->first('\\Spot\\Entity\\Post', array('title' => $post->title)));
 }
开发者ID:brandonlamb,项目名称:spot,代码行数:17,代码来源:Transactions.php


示例16: testCustomTypeRegistration

 public function testCustomTypeRegistration()
 {
     $mapper = test_spot_mapper();
     $cfg = $mapper->config();
     // Register JSON type, add json field type, and migrate
     $cfg->typeHandler('json_oneway', 'Test\\Type\\Json');
     Entity_Type::$_fields['json_oneway'] = array('type' => 'json_oneway');
     $mapper->entityManager()->resetFields();
     // Have to resetFields b/c field definitions are cached
     $this->assertArrayHasKey('json_oneway', $mapper->fields('Entity_Type'));
     $mapper->migrate('Entity_Type');
     // Save array data with JSON type
     $data = array('json_oneway' => array('a' => 'b', 'foo' => 'bar'));
     $result = $mapper->create('Entity_Type', $data);
     $this->assertTrue($result !== false);
     // Select entity from db to ensure it is saved correctly
     $entity = $mapper->get('Entity_Type', $result->id);
     $this->assertSame(json_encode($data['json_oneway']), $entity->json_oneway);
     $mapper->dropDatasource('Entity_Type');
 }
开发者ID:vlucas,项目名称:spot,代码行数:20,代码来源:Types.php


示例17: testEventSearchBelongsToEvent

 /**
  * @depends testEventInsert
  */
 public function testEventSearchBelongsToEvent($eventId)
 {
     $mapper = test_spot_mapper('SpotTest\\Entity\\Event\\Search');
     $eventSearch = $mapper->first(['event_id' => $eventId]);
     $this->assertInstanceOf('SpotTest\\Entity\\Event', $eventSearch->event->execute());
 }
开发者ID:scottstamp,项目名称:BadgeScanner,代码行数:9,代码来源:Relations.php


示例18: testSerialized

 public function testSerialized()
 {
     $data = array('title' => 'A Post', 'body' => 'A Body', 'status' => 0, 'author_id' => 1, 'data' => array('posts' => 'are cool', 'another field' => 'to serialize'));
     $post = new Entity_Post($data);
     $this->assertEquals($post->data, array('posts' => 'are cool', 'another field' => 'to serialize'));
     $mapper = test_spot_mapper();
     $mapper->save($post);
     $post = $mapper->all('Entity_Post')->first();
     $this->assertEquals($post->data, array('posts' => 'are cool', 'another field' => 'to serialize'));
     $post->data = 'asdf';
     $this->assertEquals($post->data, 'asdf');
     $mapper->save($post);
     $post = $mapper->all('Entity_Post')->first();
     $this->assertEquals($post->data, 'asdf');
 }
开发者ID:vlucas,项目名称:spot,代码行数:15,代码来源:Entity.php


示例19: testInsertEventRunsTypeOptionsValidation

 public function testInsertEventRunsTypeOptionsValidation()
 {
     $mapper = test_spot_mapper('\\SpotTest\\Entity\\Event');
     $event = new \SpotTest\Entity\Event(['title' => 'Test Event 1', 'description' => 'Test Description', 'type' => 'invalid_value', 'date_start' => new \DateTime('+1 day')]);
     $result = $mapper->insert($event);
     $this->assertFalse($result);
     $this->assertEquals(['Type contains invalid value'], $event->errors('type'));
 }
开发者ID:scottstamp,项目名称:BadgeScanner,代码行数:8,代码来源:Insert.php


示例20: testInvalidRelationClass

 /**
  * @expectedException InvalidArgumentException
  */
 public function testInvalidRelationClass()
 {
     $mapper = test_spot_mapper('SpotTest\\Entity\\Post');
     $entity = $mapper->first();
     $entity->fake = $mapper->hasOne($entity, 'Nonexistent\\Entity', 'fake_field');
     $entity->fake->something;
 }
开发者ID:GasimGasimzada,项目名称:spot2,代码行数:10,代码来源:Relations.php



注:本文中的test_spot_mapper函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP test_start函数代码示例发布时间:2022-05-23
下一篇:
PHP test_schema函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap