|
4 | 4 |
|
5 | 5 | class InsertTest extends \PHPUnit\Framework\TestCase
|
6 | 6 | {
|
| 7 | + public function testMultipleInserts() : void |
| 8 | + { |
| 9 | + $transaction = new \PHPFUI\ORM\Transaction(); |
| 10 | + $customer1 = new \Tests\App\Record\Customer(); |
| 11 | + $customer1->address = '123 Broadway'; |
| 12 | + $customer1->business_phone = '212-987-6543'; |
| 13 | + $customer1->city = 'New York'; |
| 14 | + $customer1->company = 'PHPFUI'; |
| 15 | + $customer1->country_region = 'USA'; |
| 16 | + $customer1->email_address = 'bruce@phpfui.com'; |
| 17 | + $customer1->fax_number = '212-345-6789'; |
| 18 | + $customer1->first_name = 'Bruce'; |
| 19 | + $customer1->home_phone = '987-654-3210'; |
| 20 | + $customer1->job_title = 'Head Honcho'; |
| 21 | + $customer1->last_name = 'Wells'; |
| 22 | + $customer1->mobile_phone = '123-456-7890'; |
| 23 | + $customer1->state_province = 'NY'; |
| 24 | + $customer1->web_page = 'http://www.phpfui.com'; |
| 25 | + $customer1->zip_postal_code = '10021'; |
| 26 | + |
| 27 | + $customer2 = new \Tests\App\Record\Customer(); |
| 28 | + $customer2->address = '123 Main Street'; |
| 29 | + $customer2->business_phone = '212-555-1212'; |
| 30 | + $customer2->city = 'New York City'; |
| 31 | + $customer2->company = 'PHPFUI'; |
| 32 | + $customer2->country_region = 'USA'; |
| 33 | + $customer2->email_address = 'bruce2@phpfui.com'; |
| 34 | + $customer2->fax_number = '212-111-3333'; |
| 35 | + $customer2->first_name = 'Bruce'; |
| 36 | + $customer2->home_phone = '987-654-3210'; |
| 37 | + $customer2->job_title = 'Head Honcho'; |
| 38 | + $customer2->last_name = 'Wells'; |
| 39 | + $customer2->state_province = 'NY'; |
| 40 | + $customer2->web_page = 'http://buriedtreasure.phpfui.com'; |
| 41 | + |
| 42 | + $customer3 = new \Tests\App\Record\Customer(); |
| 43 | + $customer3->address = '456 Elm'; |
| 44 | + $customer3->business_phone = '212-987-6543'; |
| 45 | + $customer3->city = 'Rochester'; |
| 46 | + $customer3->company = 'PHPFUI'; |
| 47 | + $customer3->email_address = 'bruce3@phpfui.net'; |
| 48 | + $customer3->fax_number = '212-345-6789'; |
| 49 | + $customer3->first_name = 'Fred'; |
| 50 | + $customer3->home_phone = '987-654-3210'; |
| 51 | + $customer3->job_title = 'Honcho'; |
| 52 | + $customer3->last_name = 'Willis'; |
| 53 | + $customer3->mobile_phone = '123-456-7890'; |
| 54 | + $customer3->state_province = 'NY'; |
| 55 | + |
| 56 | + $customers = []; |
| 57 | + $customers[] = $customer1; |
| 58 | + $customers[] = $customer2; |
| 59 | + $customers[] = $customer3; |
| 60 | + |
| 61 | + $customerTable = new \Tests\App\Table\Customer(); |
| 62 | + $this->assertCount(29, $customerTable); |
| 63 | + |
| 64 | + $customerTable->insert($customers); |
| 65 | + $this->assertCount(32, $customerTable); |
| 66 | + $customerTable->setWhere(new \PHPFUI\ORM\Condition('zip_postal_code', operator:new \PHPFUI\ORM\Operator\IsNull())); |
| 67 | + $this->assertCount(2, $customerTable); |
| 68 | + $customerTable->setWhere(new \PHPFUI\ORM\Condition('email_address', '%@phpfui%', new \PHPFUI\ORM\Operator\Like())); |
| 69 | + $this->assertCount(3, $customerTable); |
| 70 | + |
| 71 | + $this->assertTrue($transaction->rollBack()); |
| 72 | + $customerTable->setWhere(); |
| 73 | + $this->assertCount(29, $customerTable); |
| 74 | + } |
| 75 | + |
7 | 76 | public function testDateNullInsert() : void
|
8 | 77 | {
|
9 | 78 | $transaction = new \PHPFUI\ORM\Transaction();
|
|
0 commit comments