-
Notifications
You must be signed in to change notification settings - Fork 677
/
TestOfInstanceMySQLDAO.php
581 lines (513 loc) · 23.3 KB
/
TestOfInstanceMySQLDAO.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
<?php
require_once dirname(__FILE__).'/config.tests.inc.php';
require_once $SOURCE_ROOT_PATH.'extlib/simpletest/autorun.php';
require_once $SOURCE_ROOT_PATH.'extlib/simpletest/web_tester.php';
ini_set("include_path", ini_get("include_path").PATH_SEPARATOR.$INCLUDE_PATH);
require_once $SOURCE_ROOT_PATH.'tests/classes/class.ThinkUpUnitTestCase.php';
require_once $SOURCE_ROOT_PATH.'tests/fixtures/class.FixtureBuilder.php';
require_once $SOURCE_ROOT_PATH.'tests/fixtures/class.FixtureBuilderException.php';
require_once $SOURCE_ROOT_PATH.'webapp/model/class.InstanceMySQLDAO.php';
require_once $SOURCE_ROOT_PATH.'webapp/model/class.Instance.php';
require_once $SOURCE_ROOT_PATH.'webapp/model/class.Owner.php';
require_once $SOURCE_ROOT_PATH.'webapp/model/class.Profiler.php';
require_once $SOURCE_ROOT_PATH.'extlib/Loremipsum/LoremIpsum.class.php';
class TestOfInstanceMySQLDAO extends ThinkUpUnitTestCase {
protected $DAO;
public function __construct() {
$this->UnitTestCase('InstanceMySQLDAO class test');
}
public function setUp() {
parent::setUp();
$this->DAO = new InstanceMySQLDAO();
$q = "INSERT INTO tu_instances ";
$q .= "(`network_user_id`, `network_username`, `network`, ";
$q .= "`network_viewer_id`, `crawler_last_run`, `is_active`) VALUES ";
$q .= "(10 , 'jack', 'twitter', 10, '1988-01-20 12:00:00', 1), ";
$q .= "(12, 'jill', 'twitter', 12, '2010-01-20 12:00:00', 1), ";
$q .= "(13 , 'stuart', 'twitter', 13, '2010-01-01 12:00:00', 0), ";
$q .= "(15 , 'Jillian Dickerson', 'facebook', 15, '2010-01-01 12:00:01', 1), ";
$q .= "(16 , 'Paul Clark', 'facebook', 16, '2010-01-01 12:00:02', 0) ";
// $q .= "(17 , 'Jillian Micheals', 'facebook', 15, '2010-01-01 12:00:01', 1) ";
PDODAO::$PDO->exec($q);
$q = "INSERT INTO `tu_owner_instances` (`owner_id` , `instance_id`) ";
$q .= "VALUES ('2', '1'), ('2', '2');";
PDODAO::$PDO->exec($q);
}
public function tearDown() {
parent::tearDown();
}
public function testGetHoursSinceLastCrawlerRun() {
$dao = new InstanceMySQLDAO();
$instance_builder = FixtureBuilder::build('instances', array('crawler_last_run'=>'-3h'));
$hours = $dao->getHoursSinceLastCrawlerRun();
$this->assertEqual($hours, 3);
$instance1_builder = FixtureBuilder::build('instances', array('crawler_last_run'=>'-2h'));
$hours = $dao->getHoursSinceLastCrawlerRun();
$this->assertEqual($hours, 2);
}
public function testInsert() {
$result = $this->DAO->insert(11, 'ev');
$this->assertEqual($result, 6);
$i = $this->DAO->getByUserIdOnNetwork(11, 'twitter');
$this->assertEqual($i->network_user_id, 11);
$this->assertEqual($i->network_viewer_id, 11);
$this->assertEqual($i->network_username, 'ev');
$this->assertEqual($i->network, 'twitter');
$result = $this->DAO->insert(14, 'The White House Facebook Page', 'facebook', 10);
$this->assertEqual($result, 7);
$i = $this->DAO->getByUserIdOnNetwork(14, 'facebook');
$this->assertEqual($i->network_user_id, 14);
$this->assertEqual($i->network_viewer_id, 10);
$this->assertEqual($i->network_username, 'The White House Facebook Page');
$this->assertEqual($i->network, 'facebook');
}
public function testGetFreshestByOwnerId(){
//try one
$result = $this->DAO->getFreshestByOwnerId(2);
$this->assertIsA($result, "Instance");
$this->assertEqual($result->network_username, 'jill');
$this->assertEqual($result->network_user_id, 12);
$this->assertEqual($result->network_viewer_id, 12);
//Try a non existant one
$result = $this->DAO->getFreshestByOwnerId(3);
$this->assertNull($result);
}
public function testGetInstanceOneByLastRun(){
//Try Newest
$result = $this->DAO->getInstanceFreshestOne();
$this->assertIsA($result, "Instance");
$this->assertEqual($result->network_username, 'jill');
$this->assertEqual($result->network_user_id, 12);
$this->assertEqual($result->network_viewer_id, 12);
//Try Oldest
$result = $this->DAO->getInstanceStalestOne();
$this->assertIsA($result, "Instance");
$this->assertEqual($result->network_username, 'jack');
$this->assertEqual($result->network_user_id, 10);
$this->assertEqual($result->network_viewer_id, 10);
$q = "TRUNCATE TABLE tu_instances ";
PDODAO::$PDO->exec($q);
//Try empty
$result = $this->DAO->getInstanceStalestOne();
$this->assertNull($result);
}
public function testGetByUsername() {
//try one user
$result = $this->DAO->getByUsername('jill');
$this->assertIsA($result, "Instance");
$this->assertEqual($result->network_username, 'jill');
$this->assertEqual($result->network_user_id, 12);
$this->assertEqual($result->network_viewer_id, 12);
//try another one
$result = $this->DAO->getByUsername('jack');
$this->assertIsA($result, "Instance");
$this->assertEqual($result->network_username, 'jack');
$this->assertEqual($result->network_user_id, 10);
$this->assertEqual($result->network_viewer_id, 10);
//try non-existing one
$result = $this->DAO->getByUsername('no one');
$this->assertNull($result);
}
public function testGetByUserId() {
// data do exist
$result = $this->DAO->getByUserIdOnNetwork(10, 'twitter');
$this->assertIsA($result, "Instance");
$this->assertEqual($result->network_username, 'jack');
$this->assertEqual($result->network_user_id, 10);
$this->assertEqual($result->network_viewer_id, 10);
// data do not exist
$result = $this->DAO->getByUserIdOnNetwork(11, 'twitter');
$this->assertNull($result);
}
public function testGetAllInstances(){
//getAllInstances($order = "DESC", $only_active = false, $network = "twitter")
// Test, default settings
$result = $this->DAO->getAllInstances();
$this->assertIsA($result, "array");
$this->assertEqual(count($result), 3);
$users = array('jill','stuart','jack');
$uID = array(12,13,10);
$vID = array(12,13,10);
foreach($result as $id=>$i){
$this->assertIsA($i, "Instance");
$this->assertEqual($i->network_username, $users[$id]);
$this->assertEqual($i->network_user_id, $uID[$id]);
$this->assertEqual($i->network_viewer_id, $vID[$id]);
}
// Test ASC
$result = $this->DAO->getAllInstances("ASC");
$this->assertIsA($result, "array");
$this->assertEqual(count($result), 3);
$users = array('jack','stuart','jill');
$uID = array(10,13,12);
$vID = array(10,13,12);
foreach($result as $id=>$i){
$this->assertIsA($i, "Instance");
$this->assertEqual($i->network_username, $users[$id]);
$this->assertEqual($i->network_user_id, $uID[$id]);
$this->assertEqual($i->network_viewer_id, $vID[$id]);
}
// Test ASC Only Active
$result = $this->DAO->getAllInstances("ASC", true);
$this->assertIsA($result, "array");
$this->assertEqual(count($result), 2);
$users = array('jack','jill');
$uID = array(10,12);
$vID = array(10,12);
foreach($result as $id=>$i){
$this->assertIsA($i, "Instance");
$this->assertEqual($i->network_username, $users[$id]);
$this->assertEqual($i->network_user_id, $uID[$id]);
$this->assertEqual($i->network_viewer_id, $vID[$id]);
}
// Test ASC Facebook
$result = $this->DAO->getAllInstances("ASC", false, 'facebook');
$this->assertIsA($result, "array");
$this->assertEqual(count($result), 2);
$users = array('Jillian Dickerson','Paul Clark');
$uID = array(15,16);
$vID = array(15,16);
foreach($result as $id=>$i){
$this->assertIsA($i, "Instance");
$this->assertEqual($i->network_username, $users[$id]);
$this->assertEqual($i->network_user_id, $uID[$id]);
$this->assertEqual($i->network_viewer_id, $vID[$id]);
}
// Test ASC only active Facebook
$result = $this->DAO->getAllInstances("ASC", true, 'facebook');
$this->assertIsA($result, "array");
$this->assertEqual(count($result), 1);
$users = array('Jillian Dickerson');
$uID = array(15);
$vID = array(15);
foreach($result as $id=>$i){
$this->assertIsA($i, "Instance");
$this->assertEqual($i->network_username, $users[$id]);
$this->assertEqual($i->network_user_id, $uID[$id]);
$this->assertEqual($i->network_viewer_id, $vID[$id]);
}
}
public function testGetByOwner(){
$data = array(
'id'=>2,
'user_name'=>'steven',
'full_name'=>'Steven Warren',
'email'=>'me@example.com',
'last_login'=>'Yesterday',
'is_admin'=>1,
'is_activated'=>1
);
$owner = new Owner($data);
// Test is-admin
$result = $this->DAO->getByOwner($owner);
$this->assertIsA($result, "array");
$this->assertEqual(count($result), 5);
$users = array('jill','Paul Clark','Jillian Dickerson','stuart','jack');
$uID = array(12,16,15,13,10);
$vID = array(12,16,15,13,10);
foreach($result as $id=>$i){
$this->assertIsA($i, "Instance");
$this->assertEqual($i->network_username, $users[$id]);
$this->assertEqual($i->network_user_id, $uID[$id]);
$this->assertEqual($i->network_viewer_id, $vID[$id]);
}
// Test Is Admin - Forced Not
$result = $this->DAO->getByOwner($owner, true);
$this->assertIsA($result, "array");
$this->assertEqual(count($result), 2);
$users = array('jill','jack');
$uID = array(12,10);
$vID = array(12,10);
foreach($result as $id=>$i){
$this->assertIsA($i, "Instance");
$this->assertEqual($i->network_username, $users[$id]);
$this->assertEqual($i->network_user_id, $uID[$id]);
$this->assertEqual($i->network_viewer_id, $vID[$id]);
}
// Test not admin
$owner->is_admin = false;
$result = $this->DAO->getByOwner($owner);
$this->assertIsA($result, "array");
$this->assertEqual(count($result), 2);
$users = array('jill','jack');
$uID = array(12,10);
$vID = array(12,10);
foreach($result as $id=>$i){
$this->assertIsA($i, "Instance");
$this->assertEqual($i->network_username, $users[$id]);
$this->assertEqual($i->network_user_id, $uID[$id]);
$this->assertEqual($i->network_viewer_id, $vID[$id]);
}
$owner->id = 3;
//Try empty
$result = $this->DAO->getByOwner($owner);
$this->assertIsA($result, "array");
$this->assertEqual(count($result), 0);
}
public function testGetByOwnerAndNetwork(){
$data = array(
'id'=>2,
'user_name'=>'steven',
'full_name'=>'Steven Warren',
'email'=>'me@example.com',
'last_login'=>'Yesterday',
'is_admin'=>1,
'is_activated'=>1
);
$owner = new Owner($data);
// Test is-admin twitter
$result = $this->DAO->getByOwnerAndNetwork($owner, 'twitter');
$this->assertIsA($result, "array");
$this->assertEqual(count($result), 3);
$users = array('jill','stuart','jack');
$uID = array(12,13,10);
$vID = array(12,13,10);
foreach($result as $id=>$i){
$this->assertIsA($i, "Instance");
$this->assertEqual($i->network_username, $users[$id]);
$this->assertEqual($i->network_user_id, $uID[$id]);
$this->assertEqual($i->network_viewer_id, $vID[$id]);
}
// Test is-admin facebook
$result = $this->DAO->getByOwnerAndNetwork($owner, 'facebook');
$this->assertIsA($result, "array");
$this->assertEqual(count($result), 2);
$users = array('Paul Clark','Jillian Dickerson');
$uID = array(16,15);
$vID = array(16,15);
foreach($result as $id=>$i){
$this->assertIsA($i, "Instance");
$this->assertEqual($i->network_username, $users[$id]);
$this->assertEqual($i->network_user_id, $uID[$id]);
$this->assertEqual($i->network_viewer_id, $vID[$id]);
}
// Test is-admin Twitter, forced not
$result = $this->DAO->getByOwnerAndNetwork($owner, 'twitter', true);
$this->assertIsA($result, "array");
$this->assertEqual(count($result), 2);
$users = array('jill','jack');
$uID = array(12,10);
$vID = array(12,10);
foreach($result as $id=>$i){
$this->assertIsA($i, "Instance");
$this->assertEqual($i->network_username, $users[$id]);
$this->assertEqual($i->network_user_id, $uID[$id]);
$this->assertEqual($i->network_viewer_id, $vID[$id]);
}
// Test not admin twitter
$owner->is_admin = false;
$result = $this->DAO->getByOwnerAndNetwork($owner, 'twitter');
$this->assertIsA($result, "array");
$this->assertEqual(count($result), 2);
$users = array('jill','jack');
$uID = array(12,10);
$vID = array(12,10);
foreach($result as $id=>$i){
$this->assertIsA($i, "Instance");
$this->assertEqual($i->network_username, $users[$id]);
$this->assertEqual($i->network_user_id, $uID[$id]);
$this->assertEqual($i->network_viewer_id, $vID[$id]);
}
$owner->id = 3;
//Try empty
$result = $this->DAO->getByOwnerAndNetwork($owner, 'twitter');;
$this->assertIsA($result, "array");
$this->assertEqual(count($result), 0);
}
public function testSetPublic(){
$result = $this->DAO->setPublic(1, true);
$this->assertEqual($result, 1, "Count UpdateToTrue (%s)");
//Testing if it really works
$result = $this->DAO->getByUsername('jack');
$this->assertEqual($result->network_username, 'jack');
$this->assertEqual($result->network_user_id, 10);
$this->assertTrue($result->is_public);
$result = $this->DAO->setPublic(1, false);
$this->assertEqual($result, 1, "Count UpdateToFalse (%s)");
//Testing if it really works
$result = $this->DAO->getByUsername('jack');
$this->assertEqual($result->network_username, 'jack');
$this->assertEqual($result->network_user_id, 10);
$this->assertFalse($result->is_public);
}
public function testSetActive(){
$result = $this->DAO->setActive(1, false);
$this->assertEqual($result, 1, "Count UpdateToFalse (%s)");
//Testing if it really works
$result = $this->DAO->getByUsername('jack');
$this->assertEqual($result->network_username, 'jack');
$this->assertEqual($result->network_user_id, 10);
$this->assertFalse($result->is_active);
$result = $this->DAO->setActive(1, true);
$this->assertEqual($result, 1, "Count UpdateToTrue (%s)");
//Testing if it really works
$result = $this->DAO->getByUsername('jack');
$this->assertEqual($result->network_username, 'jack');
$this->assertEqual($result->network_user_id, 10);
$this->assertTrue($result->is_active);
}
public function testSave(){
//First we need to generate some more TestData(tm)
$loremIpsum = new LoremIpsumGenerator();
//First in line is some posts 250 Randomly generated ones, some with mentions.
$mentions = 0;
$posts = 0;
for($i=0; $i <= 250; $i++){
$sender = rand(5,16);
$data = $loremIpsum->getContent(17, 'plain');
$postid = rand(1000, 1000000);
while(isset($pic[$postid])){
$postid = rand(1000, 1000000);
}
$pic[$postid] = true;
$number = rand(1,8);
if ($number == 1 or $number == 2){
$data = "@jack ".$data;
$mentions++;
}
elseif ($number == 3){
$data = "@jill ".$data;
}
$q = "INSERT INTO `tu_posts` (`post_id`, `author_user_id`, `post_text`) ";
$q .= " VALUES ('".$postid."', '".$sender."', '".$data."');\n";
PDODAO::$PDO->exec($q);
if($sender == 10){
$posts++;
}
}
unset($pic);
//Then generate some follows
$follows = 0;
for($i=0; $i<= 150; $i++){
$follow = array("follower"=>rand(5,25), "following"=>rand(5,25));
if(!isset($fd[$follow['following']."-".$follow['follower']])){
$fd[$follow['following']."-".$follow['follower']] = true;
$q = "INSERT INTO `tu_follows` (`user_id`, `follower_id`) ";
$q .= "VALUES ( '".$follow['following']."', '".$follow['follower']."');\n";
PDODAO::$PDO->exec($q);
if($follow['following'] == 10){
$follows++;
}
}
else{
$i = $i-1;
}
}
//Lastly generate some users
$users = array(
array('id'=>10, 'name'=>'jack'),
array('id'=>12, 'name'=>'jill'),
array('id'=>13, 'name'=>'stuart'),
array('id'=>15, 'name'=>'Jillian Dickerson'),
array('id'=>16, 'name'=>'Paul Clark')
);
foreach($users as $user){
$q = "INSERT INTO `tu_users` (`user_id`, `user_name`) ";
$q .= " VALUES ('".$user['id']."', '".$user['name']."') ";
PDODAO::$PDO->exec($q);
}
//Now load the instance in question
$i = $this->DAO->getByUsername('jack');
//Edit it.
$i->last_status_id = 512;
$i->last_page_fetched_replies = 2;
$i->last_page_fetched_tweets = 17;
$i->is_archive_loaded_follows = 1;
$i->is_archive_loaded_replies = 1;
//First make sure that last run data is correct before we start.
$result = $this->DAO->getInstanceFreshestOne();
$this->assertIsA($result, "Instance");
$this->assertEqual($result->network_username, 'jill');
$this->assertEqual($result->network_user_id, 12);
$this->assertEqual($result->network_viewer_id, 12);
//Save it
$count = $this->DAO->save($i, 1024);
$this->assertEqual($count, 1);
//Load it for testing
$result = $this->DAO->getByUsername('jack');
$this->assertEqual($result->total_posts_by_owner, 1024);
$this->assertEqual($result->last_page_fetched_replies, 2);
$this->assertEqual($result->last_status_id, 512);
$this->assertEqual($result->last_page_fetched_tweets, 17);
$this->assertEqual($result->total_replies_in_system, $mentions);
$this->assertEqual($result->total_follows_in_system, $follows);
$this->assertEqual($result->total_posts_in_system, $posts);
$this->assertEqual($result->total_users_in_system, 5);
$this->assertTrue($result->is_archive_loaded_follows);
$this->assertTrue($result->is_archive_loaded_replies);
//Check if it is the update updated last Run.
$result = $this->DAO->getInstanceFreshestOne();
$this->assertIsA($result, "Instance");
$this->assertEqual($result->network_username, 'jack');
$this->assertEqual($result->network_user_id, 10);
$this->assertEqual($result->network_viewer_id, 10);
//Still needs tests for:
//earliest_reply_in_system
//earliest_post_in_system
}
public function testUpdateLastRun(){
//First make sure that the data is correct before we start.
$result = $this->DAO->getInstanceFreshestOne();
$this->assertIsA($result, "Instance");
$this->assertEqual($result->network_username, 'jill');
$this->assertEqual($result->network_user_id, 12);
$this->assertEqual($result->network_viewer_id, 12);
//preform the update, and check the result.
$result = $this->DAO->updateLastRun(1);
$this->assertEqual($result, 1);
//Check if it is the update.
$result = $this->DAO->getInstanceFreshestOne();
$this->assertIsA($result, "Instance");
$this->assertEqual($result->network_username, 'jack');
$this->assertEqual($result->network_user_id, 10);
$this->assertEqual($result->network_viewer_id, 10);
}
public function testIsUserConfigured(){
// Test user that is Configured
$result = $this->DAO->isUserConfigured("jack", "twitter");
$this->assertTrue($result);
// Test non-existing user
$result = $this->DAO->isUserConfigured("no one", "facebook");
$this->assertFalse($result);
}
public function testGetByUserAndViewerId() {
$this->DAO = new InstanceMySQLDAO();
$q = "INSERT INTO tu_instances ";
$q .= "(`network_user_id`, `network_username`, `network`, ";
$q .= "`network_viewer_id`, `crawler_last_run`, `is_active`) VALUES ";
$q .= "(17 , 'Jillian Micheals', 'facebook', 15, '2010-01-01 12:00:01', 1) ";
PDODAO::$PDO->exec($q);
$result = $this->DAO->getByUserAndViewerId(10, 10, 'twitter');
$this->assertEqual($result->network_username, 'jack');
$result = $this->DAO->getByUserAndViewerId(17, 15, 'facebook');
$this->assertEqual($result->network_username, 'Jillian Micheals');
}
public function testGetByViewerId() {
$this->DAO = new InstanceMySQLDAO();
$q = "INSERT INTO tu_instances ";
$q .= "(`network_user_id`, `network_username`, `network`, ";
$q .= "`network_viewer_id`, `crawler_last_run`, `is_active`) VALUES ";
$q .= "(17 , 'Jillian Micheals', 'facebook', 15, '2010-01-01 12:00:01', 1) ";
PDODAO::$PDO->exec($q);
$result = $this->DAO->getByViewerId(15);
$this->assertEqual($result[0]->network_username, 'Jillian Dickerson');
$this->assertEqual($result[1]->network_username, 'Jillian Micheals');
}
public function testGetByUsernameOnNetwork() {
$this->DAO = new InstanceMySQLDAO();
$q = "INSERT INTO tu_instances ";
$q .= "(`network_user_id`, `network_username`, `network`, ";
$q .= "`network_viewer_id`, `crawler_last_run`, `is_active`) VALUES ";
$q .= "(17 , 'salma', 'facebook', 15, '2010-01-01 12:00:01', 1), ";
$q .= "(18 , 'salma', 'facebook page', 15, '2010-01-01 12:00:01', 1) ";
PDODAO::$PDO->exec($q);
$result = $this->DAO->getByUsernameOnNetwork('salma', 'facebook');
$this->assertEqual($result->network_username, 'salma');
$this->assertEqual($result->network, 'facebook');
$this->assertEqual($result->network_user_id, 17);
$result = $this->DAO->getByUsernameOnNetwork('salma', 'facebook page');
$this->assertEqual($result->network_username, 'salma');
$this->assertEqual($result->network, 'facebook page');
$this->assertEqual($result->network_user_id, 18);
}
}