Skip to content

Commit 0f9f05b

Browse files
committed
Clean-up.
1 parent b81bfad commit 0f9f05b

38 files changed

+48
-1229
lines changed

testing/RedUNIT/Base/Batch.php

-25
Original file line numberDiff line numberDiff line change
@@ -73,63 +73,38 @@ public function testBatch()
7373
$writer = $toolbox->getWriter();
7474
$redbean = $toolbox->getRedBean();
7575
$pdo = $adapter->getDatabase();
76-
7776
$page = $redbean->dispense( "page" );
78-
7977
$page->name = "page no. 1";
8078
$page->rating = 1;
81-
8279
$id1 = $redbean->store( $page );
83-
8480
$page = $redbean->dispense( "page" );
85-
8681
$page->name = "page no. 2";
87-
8882
$id2 = $redbean->store( $page );
89-
9083
$batch = $redbean->batch( "page", array( $id1, $id2 ) );
91-
9284
asrt( count( $batch ), 2 );
9385
asrt( $batch[$id1]->getMeta( "type" ), "page" );
9486
asrt( $batch[$id2]->getMeta( "type" ), "page" );
9587
asrt( (int) $batch[$id1]->id, $id1 );
9688
asrt( (int) $batch[$id2]->id, $id2 );
97-
9889
$book = $redbean->dispense( "book" );
99-
10090
$book->name = "book 1";
101-
10291
$redbean->store( $book );
103-
10492
$book = $redbean->dispense( "book" );
105-
10693
$book->name = "book 2";
107-
10894
$redbean->store( $book );
109-
11095
$book = $redbean->dispense( "book" );
111-
11296
$book->name = "book 3";
113-
11497
$redbean->store( $book );
115-
11698
$books = $redbean->batch( "book", $adapter->getCol( "SELECT id FROM book" ) );
117-
11899
asrt( count( $books ), 3 );
119-
120100
$a = $redbean->batch( 'book', 9919 );
121-
122101
asrt( is_array( $a ), TRUE );
123102
asrt( count( $a ), 0 );
124103
$a = $redbean->batch( 'triangle', 1 );
125-
126104
asrt( is_array( $a ), TRUE );
127105
asrt( count( $a ), 0 );
128-
129106
R::freeze( TRUE );
130-
131107
$a = $redbean->batch( 'book', 9919 );
132-
133108
asrt( is_array( $a ), TRUE );
134109
asrt( count( $a ), 0 );
135110
try {

testing/RedUNIT/Base/Bean.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,9 @@ public function testBeau()
283283
}
284284

285285
/**
286-
* Other tests...
286+
* Misc bean tests.
287+
*
288+
* @return void
287289
*/
288290
public function testMisc()
289291
{
@@ -616,7 +618,6 @@ public function testWhetherWeCanAddToLists()
616618
$book->xownPageList[] = R::dispense('page');
617619
R::store( $book );
618620
asrt( R::count('page'), 3 );
619-
620621
$ads = R::dispense('ad', 3 );
621622
$book = $this->_createBook();
622623
$book->alias('magazine')->ownAd = $ads;
@@ -645,7 +646,6 @@ public function testWhetherWeCanAddToLists()
645646
R::store( $book );
646647
asrt( R::count('ad'), 3 );
647648
asrt( R::count('page'), 3 );
648-
649649
$book = $this->_createBook();
650650
$book->sharedTag[] = R::dispense('tag');
651651
R::store( $book );
@@ -680,7 +680,6 @@ public function testDeleteByIDs()
680680
try { R::store( $book ); fail(); }catch(\Exception $e) { pass(); }
681681
$book = $book->fresh();
682682
asrt( count( $book->ownPage ), 0 );
683-
684683
$book = $this->_createBook();
685684
$firstAd = reset( $book->alias('magazine')->ownAd );
686685
$book->alias('magazine')->ownAd[ $firstAd->id ] = NULL;

testing/RedUNIT/Base/Chill.php

-19
Original file line numberDiff line numberDiff line change
@@ -31,47 +31,29 @@ class Chill extends Base
3131
public function testChill()
3232
{
3333
$bean = R::dispense( 'bean' );
34-
3534
$bean->col1 = '1';
3635
$bean->col2 = '2';
37-
3836
R::store( $bean );
39-
4037
asrt( count( R::getWriter()->getColumns( 'bean' ) ), 3 );
41-
4238
$bean->col3 = '3';
43-
4439
R::store( $bean );
45-
4640
asrt( count( R::getWriter()->getColumns( 'bean' ) ), 4 );
47-
4841
R::freeze( array( 'umbrella' ) );
49-
5042
$bean->col4 = '4';
51-
5243
R::store( $bean );
53-
5444
asrt( count( R::getWriter()->getColumns( 'bean' ) ), 5 );
55-
5645
R::freeze( array( 'bean' ) );
57-
5846
$bean->col5 = '5';
59-
6047
try {
6148
R::store( $bean );
6249
fail();
6350
} catch (\Exception $e ) {
6451
pass();
6552
}
66-
6753
asrt( count( R::getWriter()->getColumns( 'bean' ) ), 5 );
68-
6954
R::freeze( array() );
70-
7155
$bean->col5 = '5';
72-
7356
R::store( $bean );
74-
7557
asrt( count( R::getWriter()->getColumns( 'bean' ) ), 6 );
7658
}
7759

@@ -102,7 +84,6 @@ public function testDontAddUniqueConstraintForChilledBeanTypes()
10284
pass();
10385
}
10486
asrt(R::count('person_role'), 2);
105-
10687
R::nuke();
10788
$link = R::getRedBean()->dispense('person_role');
10889
$person = R::dispense( 'person' );

testing/RedUNIT/Base/Close.php

-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ public function testClose()
5252
asrt( $e->getMessage(), 'The nuke() command has been disabled using noNuke() or R::feature(novice/...).' );
5353
}
5454
R::useFeatureSet('latest');
55-
5655
//Close
5756
R::getDatabaseAdapter()->setOption( 'setInitQuery', NULL );
5857
asrt( R::getDatabaseAdapter()->getDatabase()->isConnected(), TRUE );

testing/RedUNIT/Base/Count.php

+11-28
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,12 @@ public function testCountType()
3939
$book->sharedPage = R::dispense( 'page', 10 );
4040
R::store( $book );
4141
asrt( R::count('bookPage'), 10 );
42-
4342
try {
4443
R::count( 'WrongTypeName' );
4544
fail();
4645
} catch ( RedException $ex ) {
4746
pass();
4847
}
49-
5048
try {
5149
R::count( 'wrong_type_name' );
5250
fail();
@@ -63,62 +61,38 @@ public function testCountType()
6361
public function testCountAndWipe()
6462
{
6563
testpack( "Test count and wipe" );
66-
6764
$page = R::dispense( "page" );
68-
6965
$page->name = "ABC";
70-
7166
R::store( $page );
72-
7367
$n1 = R::count( "page" );
74-
7568
$page = R::dispense( "page" );
76-
7769
$page->name = "DEF";
78-
7970
R::store( $page );
80-
8171
$n2 = R::count( "page" );
82-
8372
asrt( $n1 + 1, $n2 );
84-
8573
R::wipe( "page" );
86-
8774
asrt( R::count( "page" ), 0 );
8875
asrt( R::getRedBean()->count( "page" ), 0 );
8976
asrt( R::getRedBean()->count( "kazoo" ), 0 ); // non existing table
90-
9177
R::freeze( TRUE );
92-
9378
try {
9479
asrt( R::getRedBean()->count( "kazoo" ), 0 ); // non existing table
9580
fail();
9681
} catch( \Exception $e ) {
9782
pass();
9883
}
99-
10084
R::freeze( FALSE );
101-
10285
$page = R::dispense( 'page' );
103-
10486
$page->name = 'foo';
105-
10687
R::store( $page );
107-
10888
$page = R::dispense( 'page' );
109-
11089
$page->name = 'bar';
111-
11290
R::store( $page );
113-
11491
asrt( R::count( 'page', ' name = ? ', array( 'foo' ) ), 1 );
115-
11692
// Now count something that does not exist, this should return 0. (just be polite)
11793
asrt( R::count( 'teapot', ' name = ? ', array( 'flying' ) ), 0 );
11894
asrt( R::count( 'teapot' ), 0 );
119-
12095
$currentDriver = $this->currentlyActiveDriverID;
121-
12296
// Some drivers don't support that many error codes.
12397
if ( $currentDriver === 'mysql' || $currentDriver === 'postgres' ) {
12498
try {
@@ -130,8 +104,13 @@ public function testCountAndWipe()
130104
}
131105
}
132106

133-
public function testCountShared() {
134-
107+
/**
108+
* Can we count the number of shared beans?
109+
*
110+
* @return void
111+
*/
112+
public function testCountShared()
113+
{
135114
R::nuke();
136115
$book = R::dispense( 'book' );
137116
$book->sharedPageList = R::dispense( 'page', 5 );
@@ -157,6 +136,8 @@ public function testCountShared() {
157136

158137
/**
159138
* Test $bean->countOwn($type);
139+
*
140+
* @return void
160141
*/
161142
public function testCountOwn()
162143
{
@@ -198,6 +179,8 @@ public function testCountOwn()
198179

199180
/**
200181
* Test $bean->withCondition( ... )->countOwn( $type );
182+
*
183+
* @return void
201184
*/
202185
public function testCountWithCondition()
203186
{

0 commit comments

Comments
 (0)