From: Steve Sutton Date: Tue, 24 Sep 2013 19:38:34 +0000 (-0400) Subject: Add new sources X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=1d20da5b7dcf2230f5fdf1e2f5bf8c17205918c4;p=user%2Fsteve%2FnetBeansUptraUnitTest.git Add new sources Grabing these test files from my virtual machine. Hopefully I'll be able to get them to work on my PHP 5.4 machine. --- 1d20da5b7dcf2230f5fdf1e2f5bf8c17205918c4 diff --git a/Toolkit/Members/Billing/Toolkit_Members_Billing_BillingTest.php b/Toolkit/Members/Billing/Toolkit_Members_Billing_BillingTest.php new file mode 100644 index 0000000..dfede00 --- /dev/null +++ b/Toolkit/Members/Billing/Toolkit_Members_Billing_BillingTest.php @@ -0,0 +1,254 @@ + PDO::FETCH_ASSOC + ); + + $this->pdo = new PDO($dsn, null, null, $driverOptions); + $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + $file = TEST_PATH . 'Toolkit/Members/files/memberdb.sql'; + Toolkit_Common::createTables($this->pdo, $file); + + $this->object = new Toolkit_Members_Billing_Billing; + } + + protected function getDatabaseTester() + { + $connection = new PHPUnit_Extensions_Database_DB_DefaultDatabaseConnection($this->pdo, 'demo'); + $tester = new PHPUnit_Extensions_Database_DefaultTester($connection); + + $tester->setSetUpOperation(PHPUnit_Extensions_Database_Operation_Factory::CLEAN_INSERT()); + $tester->setTearDownOperation(PHPUnit_Extensions_Database_Operation_Factory::NONE()); + $data = new PHPUnit_Extensions_Database_DataSet_FlatXmlDataSet( + TEST_PATH . 'Toolkit/Members/files/members-seed.xml'); + $tester->setDataSet($data); + + return $tester; + } + + protected function getDataSet($file) + { + return new PHPUnit_Extensions_Database_DataSet_FlatXMLDataSet($file); + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() { + + } + + /** + * @todo Implement testSetBilling_type(). + */ + public function testSetBilling_type() { + $ret = $this->object->setBilling_type(1); + $this->assertInstanceOf('Toolkit_Members_Billing_Billing', $ret); + } + + /** + * @todo Implement testSetPaid(). + */ + public function testSetPaid() { + $ret = $this->object->setPaid(true); + $this->assertInstanceOf('Toolkit_Members_Billing_Billing', $ret); + } + + /** + * @todo Implement testSetPayment_method(). + */ + public function testSetPayment_method() { + $ret = $this->object->setPayment_method(1); + $this->assertInstanceOf('Toolkit_Members_Billing_Billing', $ret); + } + + /** + * @todo Implement testSetPayment_method(). + */ + public function testSetPayment_method_empty() { + $ret = $this->object->setPayment_method(null); + $this->assertInstanceOf('Toolkit_Members_Billing_Billing', $ret); + } + + public function testSetAmount() { + $ret = $this->object->setAmount(null); + $this->assertInstanceOf('Toolkit_Members_Billing_Billing', $ret); + $ret = $this->object->setAmount(12); + $this->assertInstanceOf('Toolkit_Members_Billing_Billing', $ret); + } + + public function testGetAmountReturnsFloat() + { + $ret = $this->object->getAmount(); + $this->assertInternalType('float', $ret); + } + + public function testGetBalanceReturnsFloat() + { + $ret = $this->object->getBalance(); + $this->assertInternalType('float', $ret); + } + + /** + * @expectedException InvalidArgumentException + */ + public function testSetBadAmount() { + $ret = $this->object->setAmount('hhh'); + } + + public function testSetBalance() { + $ret = $this->object->setBalance(null); + $this->assertInstanceOf('Toolkit_Members_Billing_Billing', $ret); + $ret = $this->object->setBalance(12); + $this->assertInstanceOf('Toolkit_Members_Billing_Billing', $ret); + } + + /** + * @expectedException InvalidArgumentException + */ + public function testSetBadBalance() { + $ret = $this->object->setBalance('hhh'); + } + + /** + * @todo Implement testSetMember_id(). + */ + public function testSetMember_id() { + $ret = $this->object->setMember_id(null); + $this->assertInstanceOf('Toolkit_Members_Billing_Billing', $ret); + $ret = $this->object->setMember_id(12); + $this->assertInstanceOf('Toolkit_Members_Billing_Billing', $ret); + } + + /** + * @expectedException InvalidArgumentException + */ + public function testSetBadMember_id() { + $ret = $this->object->setMember_id('hhh'); + } + + /** + * @todo Implement testSetEmailed(). + */ + public function testSetEmailed() { + $ret = $this->object->setEmailed(true); + $this->assertInstanceOf('Toolkit_Members_Billing_Billing', $ret); + } + + /** + * @todo Implement testSetPrinted(). + */ + public function testSetPrinted() { + $ret = $this->object->setPrinted(true); + $this->assertInstanceOf('Toolkit_Members_Billing_Billing', $ret); + } + + /** + * @expectedException InvalidArgumentException + */ + public function testExceptionFromBadSetBillingType() + { + $ret = $this->object->setBilling_type(null); + $ret = $this->object->setBilling_type(9); + } + + /** + * @expectedException InvalidArgumentException + */ + public function testExceptionFromBadSetBillingTypeNumber() + { + $ret = $this->object->setBilling_type(9); + } + + /** + * @expectedException InvalidArgumentException + */ + public function testExceptionFromBadSetPaymentMethod() + { + $ret = $this->object->setPayment_method('nen'); + } + + public function testInsertBilling() + { + $tester = $this->getDatabaseTester(); + $tester->onSetUp(); + + $stub = $this->getMock( + 'Toolkit_Members_Billing_Billing', + array('insert') + ); + $stub->expects($this->once()) + ->method('insert'); + $stub->insert($this->pdo); + +// $ret = Toolkit_Members_Billing_Factory::createDbObjectByValues( +// 'Toolkit_Members_Billing_Billing', +// array( +// 'invoice_id' => 1, +// 'transaction_time' => '2011-02-02', +// 'transaction_date' => '2011-02-02', +// 'member_name' => 'Gaslight Media', +// 'member_id' => '1', +// 'account_number' => '8974789342', +// 'billing_type' => 1, +// 'amount' => '350.00', +// 'payment_method' => 1, +// 'payment_data' => '#47646', +// 'paid' => 't', +// 'notes' => '', +// 'invoices' => '', +// ) +// ); +// $this->assertInstanceOf('Toolkit_Members_Billing_Billing', $ret); +// $ret->save($this->pdo); + + $tester->onTearDown(); + } + + public function testUpdateBilling() + { + $tester = $this->getDatabaseTester(); + $tester->onSetUp(); + +// $ret = Toolkit_Members_Billing_Factory::createDbObjectById( +// $this->pdo, +// 'Toolkit_Members_Billing_Billing', +// 1 +// ); +// $this->assertInstanceOf('Toolkit_Members_Billing_Billing', $ret); +// $ret->save($this->pdo); + + $stub = $this->getMock('Toolkit_Members_Billing_Billing'); + $stub->update($this->pdo); + + $tester->onTearDown(); + } +} + +?> diff --git a/Toolkit/Members/Billing/Toolkit_Members_Billing_FactoryTest.php b/Toolkit/Members/Billing/Toolkit_Members_Billing_FactoryTest.php new file mode 100644 index 0000000..7bbb7c8 --- /dev/null +++ b/Toolkit/Members/Billing/Toolkit_Members_Billing_FactoryTest.php @@ -0,0 +1,192 @@ + PDO::FETCH_ASSOC + ); + + $this->pdo = new PDO($dsn, null, null, $driverOptions); + $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + $file = TEST_PATH . 'Toolkit/Members/files/memberdb.sql'; + Toolkit_Common::createTables($this->pdo, $file); + + $this->object = new Toolkit_Members_Billing_Factory; + } + + protected function getDatabaseTester() + { + $connection = new PHPUnit_Extensions_Database_DB_DefaultDatabaseConnection($this->pdo, 'demo'); + $tester = new PHPUnit_Extensions_Database_DefaultTester($connection); + + $tester->setSetUpOperation(PHPUnit_Extensions_Database_Operation_Factory::CLEAN_INSERT()); + $tester->setTearDownOperation(PHPUnit_Extensions_Database_Operation_Factory::NONE()); + $data = new PHPUnit_Extensions_Database_DataSet_FlatXmlDataSet( + TEST_PATH . 'Toolkit/Members/files/members-seed.xml'); + $tester->setDataSet($data); + + return $tester; + } + + protected function getDataSet($file) + { + return new PHPUnit_Extensions_Database_DataSet_FlatXMLDataSet($file); + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() { + + } + + public function testCreateBillingObjectById() + { + $tester = $this->getDatabaseTester(); + $tester->onSetUp(); + + $ret = $this->object->createDbObjectById( + $this->pdo, + 'Toolkit_Members_Billing_Billing', + 1 + ); + $this->assertInstanceOf('Toolkit_Members_Billing_Billing', $ret); + + $tester->onTearDown(); + } + public function testCreateMemberAccountObjectById() + { + $tester = $this->getDatabaseTester(); + $tester->onSetUp(); + + $ret = $this->object->createDbObjectById( + $this->pdo, + 'Toolkit_Members_Billing_MemberAccount', + 1 + ); + $this->assertInstanceOf('Toolkit_Members_Billing_MemberAccount', $ret); + + $tester->onTearDown(); + } + public function testCreatePaymentTypesObjectById() + { + $ret = $this->object->createDbObjectById( + $this->pdo, + 'Toolkit_Members_Billing_PaymentTypes', + 1 + ); + $this->assertInstanceOf('Toolkit_Members_Billing_PaymentTypes', $ret); + } + + public function testCreateBillingObjectByValues() + { + $ret = $this->object->createDbObjectByValues( + 'Toolkit_Members_Billing_Billing', + array( + 'invoice_id' => 1, + 'transaction_time' => '2011-02-02', + 'transaction_date' => '2011-02-02', + 'member_name' => 'Gaslight Media', + 'member_id' => '1', + 'account_number' => '8974789342', + 'billing_type' => 1, + 'amount' => '350.00', + 'payment_method' => 1, + 'payment_data' => '#47646', + 'paid' => 't', + 'notes' => '', + 'invoices' => '', + ) + ); + $this->assertInstanceOf('Toolkit_Members_Billing_Billing', $ret); + } + + public function testCreatePaymentTypesObjectByValues() + { + $ret = $this->object->createDbObjectByValues( + 'Toolkit_Members_Billing_PaymentTypes', + array( + 'name' => 'Basic Member', + 'category' => 'test category', + 'qcode' => 4545, + 'amount' => '350.00', + 'notes' => '' + ) + ); + $this->assertInstanceOf('Toolkit_Members_Billing_PaymentTypes', $ret); + } + + public function testCreateMemberAccountObjectByValues() + { + $ret = $this->object->createDBObjectByValues( + 'Toolkit_Members_Billing_MemberAccount', + array( + 'member_id' => 1, + 'payment_type' => 1, + 'email_invoice' => 1, + 'usmail_invoice' => 1, + 'fax_invoice' => 1 + ) + ); + } + + public function testNothingFromBillingWhenNoClassGiven() + { + $ret = $this->object->createDBObjectByValues('', array()); + $this->assertNotInstanceOf('Toolkit_Members_Billing_Billing', $ret); + } + + public function testNothingFromPaymentTypesWhenNoClassGiven() + { + $ret = $this->object->createDBObjectById($this->pdo, '', 1); + $this->assertNotInstanceOf('Toolkit_Members_Billing_PaymentTypes', $ret); + } + /** + * @expectedException InvalidArgumentException + */ + public function testBadCallById() + { + $ret = $this->object->createDbObjectById( + $this->pdo, + 'Toolkit_Members_Billing_PaymentTypes', + 'favorite' + ); + } + + /** + * @expectedException InvalidArgumentException + */ + public function testBadCallByValues() + { + $ret = $this->object->createDBObjectByValues( + 'Toolkit_Members_Billing_PaymentTypes', + null + ); + } +} + +?> diff --git a/Toolkit/Members/Billing/Toolkit_Members_Billing_InvoicesTest.php b/Toolkit/Members/Billing/Toolkit_Members_Billing_InvoicesTest.php new file mode 100644 index 0000000..448fab8 --- /dev/null +++ b/Toolkit/Members/Billing/Toolkit_Members_Billing_InvoicesTest.php @@ -0,0 +1,185 @@ + PDO::FETCH_ASSOC + ); + + $this->pdo = new PDO($dsn, null, null, $driverOptions); + $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + $file = TEST_PATH . 'Toolkit/Members/files/memberdb.sql'; + Toolkit_Common::createTables($this->pdo, $file); + + $this->object = new Toolkit_Members_Billing_Invoices(); + + } + + protected function getDatabaseTester() + { + $connection = new PHPUnit_Extensions_Database_DB_DefaultDatabaseConnection($this->pdo, 'demo'); + $tester = new PHPUnit_Extensions_Database_DefaultTester($connection); + + $tester->setSetUpOperation(PHPUnit_Extensions_Database_Operation_Factory::CLEAN_INSERT()); + $tester->setTearDownOperation(PHPUnit_Extensions_Database_Operation_Factory::NONE()); + $data = new PHPUnit_Extensions_Database_DataSet_FlatXmlDataSet( + TEST_PATH . 'Toolkit/Members/files/members-seed.xml'); + $tester->setDataSet($data); + + return $tester; + } + + protected function getDataSet($file) + { + return new PHPUnit_Extensions_Database_DataSet_FlatXMLDataSet($file); + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() { + + } + + /** + * @todo Implement testCreateInvoices(). + */ + public function testCreateInvoices() { + $tester = $this->getDatabaseTester(); + $tester->onSetUp(); + + $members = $this->object->createInvoices($this->pdo); + + $tester->onTearDown(); + } + + /** + * @todo Implement testGetCurrentInvoiceDate(). + */ + public function testGetCurrentInvoiceDate() { + $day = 1; + $month = 7; + $year = date('Y'); + $time = mktime( + 0, + 0, + 0, + $month, + $day, + $year + ); + $invoiceDate = date('U', $time); + $return = $this->object->getCurrentInvoiceDate(true); + $this->assertEquals($invoiceDate, $return, 'Not equal'); + } + + /** + * @todo Implement testGetNextInvoiceDate(). + */ + public function testGetNextInvoiceDate() { + $day = 1; + $month = 7; + $year + = (date('n') >= 7) + ? date('Y') + 1 + : date('Y'); + $time = mktime( + 0, + 0, + 0, + $month, + $day, + $year + ); + $invoiceDate = date('U', $time); + $return = $this->object->getNextInvoiceDate(); + $this->assertEquals($invoiceDate, $return, 'Not equal'); + } + + /** + * @todo Implement testHasInvoice(). + */ + public function testHasInvoice() { + $tester = $this->getDatabaseTester(); + $tester->onSetUp(); + + $member = array( + 'member_id' => 1, + 'account_id' => 1 + ); + $hasInvoice = ($this->object->hasInvoice($this->pdo, $member)); + $this->assertTrue($hasInvoice); + + $tester->onTearDown(); + } + + public function testGetMemberDataFromId() + { + $tester = $this->getDatabaseTester(); + $tester->onSetUp(); + + $ret = $this->object->getMemberData($this->pdo, 1); + $this->assertEquals('AAA Test Business 1', $ret['member_name']); + + $tester->onTearDown(); + } + + public function testAddInvoice() + { + $tester = $this->getDatabaseTester(); + $tester->onSetup(); + + $member = array( + 'member_id' => 2, + 'payment_type' => 1 + ); + + $mockObject = $this->getMock( + 'Toolkit_Members_Billing_Invoices' + ); + $mockObject->expects($this->any()) + ->method('hasInvoice') + ->will($this->returnValue(false)); + + $members = $mockObject->addInvoice($this->pdo, $member); + + $tester->onTearDown(); + } + + /** + * @expected PDOException + */ + public function testGetMemberDataBadPDO() + { + $this->object->getMemberData($this->pdo, 'help'); + } + +} + +?> diff --git a/Toolkit/Members/Billing/Toolkit_Members_Billing_MemberAccountTest.php b/Toolkit/Members/Billing/Toolkit_Members_Billing_MemberAccountTest.php new file mode 100644 index 0000000..922316a --- /dev/null +++ b/Toolkit/Members/Billing/Toolkit_Members_Billing_MemberAccountTest.php @@ -0,0 +1,134 @@ + PDO::FETCH_ASSOC + ); + + $this->pdo = new PDO($dsn, null, null, $driverOptions); + $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + $file = TEST_PATH . 'Toolkit/Members/files/memberdb.sql'; + Toolkit_Common::createTables($this->pdo, $file); + + $this->object = new Toolkit_Members_Billing_MemberAccount(); + } + protected function getDatabaseTester() + { + $connection = new PHPUnit_Extensions_Database_DB_DefaultDatabaseConnection($this->pdo, 'demo'); + $tester = new PHPUnit_Extensions_Database_DefaultTester($connection); + + $tester->setSetUpOperation(PHPUnit_Extensions_Database_Operation_Factory::CLEAN_INSERT()); + $tester->setTearDownOperation(PHPUnit_Extensions_Database_Operation_Factory::NONE()); + $data = new PHPUnit_Extensions_Database_DataSet_FlatXmlDataSet( + TEST_PATH . 'Toolkit/Members/files/members-seed.xml'); + $tester->setDataSet($data); + + return $tester; + } + + protected function getDataSet($file) + { + return new PHPUnit_Extensions_Database_DataSet_FlatXMLDataSet($file); + } + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() { + + } + + /** + * @todo Implement testSetEmail_invoice(). + */ + public function testSetEmail_invoice() { + $ret = $this->object->setEmail_invoice(true); + $this->assertInstanceOf('Toolkit_Members_Billing_MemberAccount', $ret); + } + + /** + * @todo Implement testSetUsmail_invoice(). + */ + public function testSetUsmail_invoice() { + $ret = $this->object->setUsmail_invoice(true); + $this->assertInstanceOf('Toolkit_Members_Billing_MemberAccount', $ret); + } + + /** + * @todo Implement testSetFax_invoice(). + */ + public function testSetFax_invoice() { + $ret = $this->object->setFax_invoice(true); + $this->assertInstanceOf('Toolkit_Members_Billing_MemberAccount', $ret); + } + + /** + * @todo Implement testSetPayment_type(). + */ + public function testSetPayment_type() { + $ret = $this->object->setPayment_type(1); + $this->assertInstanceOf('Toolkit_Members_Billing_MemberAccount', $ret); + } + + /** + * @todo Implement testSetMember_id(). + */ + public function testSetMember_id() { + $ret = $this->object->setMember_id(1); + $this->assertInstanceOf('Toolkit_Members_Billing_MemberAccount', $ret); + } + + /** + * @expectedException InvalidArgumentException + */ + public function testSetMemberIdBadThrowsException() + { + $member_id = 'five'; + $this->object->setMember_id($member_id); + } + + /** + * @expectedException InvalidArgumentException + */ + public function testSetPaymentTypeBadThrowsException() + { + $payment_type = 'five'; + $this->object->setPayment_type($payment_type); + } + + /** + * @expectedException Exception + */ + public function testBadAttributeThrowsException() + { + $this->object->setNo_attribute_found(true); + } + +} + +?> diff --git a/Toolkit/Members/Billing/Toolkit_Members_Billing_MemberListsTest.php b/Toolkit/Members/Billing/Toolkit_Members_Billing_MemberListsTest.php new file mode 100644 index 0000000..37c5994 --- /dev/null +++ b/Toolkit/Members/Billing/Toolkit_Members_Billing_MemberListsTest.php @@ -0,0 +1,130 @@ + PDO::FETCH_ASSOC + ); + + $this->pdo = new PDO($dsn, null, null, $driverOptions); + $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + $file = TEST_PATH . 'Toolkit/Members/files/memberdb.sql'; + Toolkit_Common::createTables($this->pdo, $file); + + $this->object = new Toolkit_Members_Billing_MemberLists($this->pdo); + } + + protected function getDatabaseTester() + { + $connection = new PHPUnit_Extensions_Database_DB_DefaultDatabaseConnection($this->pdo, 'demo'); + $tester = new PHPUnit_Extensions_Database_DefaultTester($connection); + + $tester->setSetUpOperation(PHPUnit_Extensions_Database_Operation_Factory::CLEAN_INSERT()); + $tester->setTearDownOperation(PHPUnit_Extensions_Database_Operation_Factory::NONE()); + $data = new PHPUnit_Extensions_Database_DataSet_FlatXmlDataSet( + TEST_PATH . 'Toolkit/Members/files/members-seed.xml'); + $tester->setDataSet($data); + + return $tester; + } + + protected function getDataSet($file) + { + return new PHPUnit_Extensions_Database_DataSet_FlatXMLDataSet($file); + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + + } + + /** + * @todo Implement testGetOpenAccounts(). + */ + public function testGetOpenAccounts() + { + $ret = $this->object->getOpenAccounts(); + } + + /** + * @todo Implement testGetAccountsByAge(). + */ + public function testGetAccountsByAge() + { + $ret = $this->object->getAccountsByAge(); + } + + /** + * @todo Implement testGetClosedAccounts(). + */ + public function testGetClosedAccounts() + { + $ret = $this->object->getClosedAccounts(); + } + + /** + * @todo Implement testGetPrintableInvoices(). + */ + public function testGetPrintableInvoices() + { + $ret = $this->object->getPrintableInvoices(); + } + + /** + * @todo Implement testGetEmailableInvoices(). + */ + public function testGetEmailableInvoices() + { + $ret = $this->object->getEmailableInvoices(); + } + + /** + * @todo Implement testGetMailableInvoices(). + */ + public function testGetMailableInvoices() + { + $ret = $this->object->getMailableInvoices(); + } + + /** + * @todo Implement testGetNeededInvoices(). + */ + public function testGetNeededInvoices() + { + $ret = $this->object->getNeededInvoices(); + } + +} + +?> diff --git a/Toolkit/Members/Billing/Toolkit_Members_Billing_PaymentTypesTest.php b/Toolkit/Members/Billing/Toolkit_Members_Billing_PaymentTypesTest.php new file mode 100644 index 0000000..ceeb483 --- /dev/null +++ b/Toolkit/Members/Billing/Toolkit_Members_Billing_PaymentTypesTest.php @@ -0,0 +1,71 @@ + PDO::FETCH_ASSOC + ); + + $this->pdo = new PDO($dsn, null, null, $driverOptions); + $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + $file = TEST_PATH . 'Toolkit/Members/files/memberdb.sql'; + Toolkit_Common::createTables($this->pdo, $file); + + $this->object = new Toolkit_Members_Billing_PaymentTypes; + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() { + + } + + public function testCreatesObject() + { + $this->assertInstanceOf('Toolkit_Members_Billing_PaymentTypes', $this->object); + } + + public function testSetQcode() + { + $ret = $this->object->setQcode(1); + $this->assertInstanceOf('Toolkit_Members_Billing_PaymentTypes', $ret); + $this->assertEquals(1, $ret->getQcode(), 'qcode given does not match what is is object'); + } + + /** + * @throws InvalidArgumentException + * @expectedException InvalidArgumentException + */ + public function testSetQcodeWithInvalidParameter() + { + $ret = $this->object->setQcode('invalid number'); + } +} + +?> diff --git a/Toolkit/Members/Billing/Toolkit_Members_Billing_StatementTest.php b/Toolkit/Members/Billing/Toolkit_Members_Billing_StatementTest.php new file mode 100644 index 0000000..15c67ce --- /dev/null +++ b/Toolkit/Members/Billing/Toolkit_Members_Billing_StatementTest.php @@ -0,0 +1,146 @@ + PDO::FETCH_ASSOC + ); + + $this->pdo = new PDO($dsn, null, null, $driverOptions); + $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + $file = TEST_PATH . 'Toolkit/Members/files/memberdb.sql'; + Toolkit_Common::createTables($this->pdo, $file); + + $this->object = new Toolkit_Members_Billing_Statement(); + } + + protected function getDatabaseTester() + { + $connection = new PHPUnit_Extensions_Database_DB_DefaultDatabaseConnection($this->pdo, 'demo'); + $tester = new PHPUnit_Extensions_Database_DefaultTester($connection); + + $tester->setSetUpOperation(PHPUnit_Extensions_Database_Operation_Factory::CLEAN_INSERT()); + $tester->setTearDownOperation(PHPUnit_Extensions_Database_Operation_Factory::NONE()); + $data = new PHPUnit_Extensions_Database_DataSet_FlatXmlDataSet( + TEST_PATH . 'Toolkit/Members/files/members-seed.xml'); + $tester->setDataSet($data); + + return $tester; + } + + protected function getDataSet($file) + { + return new PHPUnit_Extensions_Database_DataSet_FlatXMLDataSet($file); + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() { + + } + + /** + * @todo Implement testGetBalanceDue(). + */ + public function testGetBalanceDue() { + $ret = $this->object->getBalanceDue( + $this->pdo, + 1, + 1 + ); + $this->assertEquals('0.00', $ret); + } + /** + * @expectedException InvalidArgumentException + */ + public function testBadCallGetBalanceDueThrowsException() + { + $ret = $this->object->getBalanceDue( + $this->pdo, + 'setme', + 1 + ); + $this->assertEquals('0.00', $ret); + } + + public function testCreateMemberStatements() + { + $tester = $this->getDatabaseTester(); + $tester->onSetUp(); + + $_REQUEST['id'] = 1; + $ret = $this->object->createMemberStatements( + $this->pdo, + 1 + ); + + $tester->onTearDown(); + } + public function testCreateAllMemberStatements() + { + $tester = $this->getDatabaseTester(); + $tester->onSetUp(); + + $_REQUEST['id'] = 1; + $ret = $this->object->createMemberStatements( + $this->pdo, + 1, + true + ); + + $tester->onTearDown(); + } + + /** + * @expectedException InvalidArgumentException + */ + public function testSetMemberIdBadThrowsException() + { + $_REQUEST['id'] = 1; + $ret = $this->object->createMemberStatements( + $this->pdo, + 'not a number', + true + ); + } + + /** + * @expected PDOException + */ + public function testGetMemberDataBadPDO() + { + $_REQUEST['id'] = 1; + $ret = $this->object->createMemberStatements( + $this->pdo, + 1, + true + ); + } +} + +?> diff --git a/Toolkit/Members/files/memberdb.sql b/Toolkit/Members/files/memberdb.sql new file mode 100644 index 0000000..8c41599 --- /dev/null +++ b/Toolkit/Members/files/memberdb.sql @@ -0,0 +1,350 @@ +CREATE TABLE state ( +state_id integer PRIMARY KEY, +state_name text, +state_abb varchar(2) +); + +DELETE FROM state; +INSERT INTO state (state_name, state_abb) VALUES ('Alabama', 'AL'); +INSERT INTO state (state_name, state_abb) VALUES ('Alaska', 'AK'); +INSERT INTO state (state_name, state_abb) VALUES ('Arizona', 'AZ'); +INSERT INTO state (state_name, state_abb) VALUES ('Arkansas', 'AR'); +INSERT INTO state (state_name, state_abb) VALUES ('California', 'CA'); +INSERT INTO state (state_name, state_abb) VALUES ('Colorado', 'CO'); +INSERT INTO state (state_name, state_abb) VALUES ('Connecticut', 'CT'); +INSERT INTO state (state_name, state_abb) VALUES ('Delaware', 'DE'); +INSERT INTO state (state_name, state_abb) VALUES ('District of Columbia', 'DC'); +INSERT INTO state (state_name, state_abb) VALUES ('Florida', 'FL'); +INSERT INTO state (state_name, state_abb) VALUES ('Georgia', 'GA'); +INSERT INTO state (state_name, state_abb) VALUES ('Hawaii', 'HI'); +INSERT INTO state (state_name, state_abb) VALUES ('Idaho', 'ID'); +INSERT INTO state (state_name, state_abb) VALUES ('Illinois', 'IL'); +INSERT INTO state (state_name, state_abb) VALUES ('Indiana', 'IN'); +INSERT INTO state (state_name, state_abb) VALUES ('Iowa', 'IA'); +INSERT INTO state (state_name, state_abb) VALUES ('Kansas', 'KS'); +INSERT INTO state (state_name, state_abb) VALUES ('Kentucky', 'KY'); +INSERT INTO state (state_name, state_abb) VALUES ('Louisiana', 'LA'); +INSERT INTO state (state_name, state_abb) VALUES ('Maine', 'ME'); +INSERT INTO state (state_name, state_abb) VALUES ('Maryland', 'MD'); +INSERT INTO state (state_name, state_abb) VALUES ('Massachusetts', 'MA'); +INSERT INTO state (state_name, state_abb) VALUES ('Michigan', 'MI'); +INSERT INTO state (state_name, state_abb) VALUES ('Minnesota', 'MN'); +INSERT INTO state (state_name, state_abb) VALUES ('Mississppi', 'MS'); +INSERT INTO state (state_name, state_abb) VALUES ('Missouri', 'MO'); +INSERT INTO state (state_name, state_abb) VALUES ('Montana', 'MT'); +INSERT INTO state (state_name, state_abb) VALUES ('Nebraska', 'NE'); +INSERT INTO state (state_name, state_abb) VALUES ('Nevada', 'NV'); +INSERT INTO state (state_name, state_abb) VALUES ('New Hampshire', 'NH'); +INSERT INTO state (state_name, state_abb) VALUES ('New Jersey', 'NJ'); +INSERT INTO state (state_name, state_abb) VALUES ('New Mexico', 'NM'); +INSERT INTO state (state_name, state_abb) VALUES ('New York', 'NY'); +INSERT INTO state (state_name, state_abb) VALUES ('North Carolina', 'NC'); +INSERT INTO state (state_name, state_abb) VALUES ('North Dakota', 'ND'); +INSERT INTO state (state_name, state_abb) VALUES ('Ohio', 'OH'); +INSERT INTO state (state_name, state_abb) VALUES ('Oklahoma', 'OK'); +INSERT INTO state (state_name, state_abb) VALUES ('Oregon', 'OR'); +INSERT INTO state (state_name, state_abb) VALUES ('Pennsylvania', 'PA'); +INSERT INTO state (state_name, state_abb) VALUES ('Rhode Island', 'RI'); +INSERT INTO state (state_name, state_abb) VALUES ('South Carolina', 'SC'); +INSERT INTO state (state_name, state_abb) VALUES ('South Dakota', 'SD'); +INSERT INTO state (state_name, state_abb) VALUES ('Tennessee', 'TN'); +INSERT INTO state (state_name, state_abb) VALUES ('Texas', 'TX'); +INSERT INTO state (state_name, state_abb) VALUES ('Utah', 'UT'); +INSERT INTO state (state_name, state_abb) VALUES ('Vermont', 'VT'); +INSERT INTO state (state_name, state_abb) VALUES ('Virginia', 'VA'); +INSERT INTO state (state_name, state_abb) VALUES ('Washington', 'WA'); +INSERT INTO state (state_name, state_abb) VALUES ('West Virginia', 'WV'); +INSERT INTO state (state_name, state_abb) VALUES ('Wisconsin', 'WI'); +INSERT INTO state (state_name, state_abb) VALUES ('Wyoming', 'WY'); +INSERT INTO state (state_name, state_abb) VALUES ('Alberta', 'AB'); +INSERT INTO state (state_name, state_abb) VALUES ('American Samoa', 'AS'); +INSERT INTO state (state_name, state_abb) VALUES ('British Columbia', 'BC'); +INSERT INTO state (state_name, state_abb) VALUES ('Federated States of Micronesia', 'FM'); +INSERT INTO state (state_name, state_abb) VALUES ('Guam', 'GU'); +INSERT INTO state (state_name, state_abb) VALUES ('Manitoba', 'MB'); +INSERT INTO state (state_name, state_abb) VALUES ('Marshall Islands', 'MH'); +INSERT INTO state (state_name, state_abb) VALUES ('New Brunswick', 'NB'); +INSERT INTO state (state_name, state_abb) VALUES ('Newfoundland', 'NF'); +INSERT INTO state (state_name, state_abb) VALUES ('Northern Mariana Islands', 'MP'); +INSERT INTO state (state_name, state_abb) VALUES ('Northwest Territories', 'NT'); +INSERT INTO state (state_name, state_abb) VALUES ('Nova Scotia', 'NS'); +INSERT INTO state (state_name, state_abb) VALUES ('Ontario', 'ON'); +INSERT INTO state (state_name, state_abb) VALUES ('Palau', 'PW'); +INSERT INTO state (state_name, state_abb) VALUES ('Prince Edward Island', 'PE'); +INSERT INTO state (state_name, state_abb) VALUES ('Puerto Rico', 'PR'); +INSERT INTO state (state_name, state_abb) VALUES ('Quebec', 'QC'); +INSERT INTO state (state_name, state_abb) VALUES ('Saskatchewan', 'SK'); +INSERT INTO state (state_name, state_abb) VALUES ('Virgin Islands', 'VI'); +INSERT INTO state (state_name, state_abb) VALUES ('Yukon', 'YT'); + +CREATE TABLE region ( +region_id integer PRIMARY KEY, +region_name text UNIQUE +); + +INSERT INTO region (region_name) VALUES ('Temp Region'); + +CREATE TABLE county ( +county_id integer PRIMARY KEY, +state_id integer REFERENCES state(state_id) ON DELETE CASCADE, +county_name text, +region_id integer REFERENCES region(region_id) ON DELETE CASCADE +); + +INSERT INTO county(state_id, county_name, region_id) VALUES (1, 'Temp County', 1); + +CREATE TABLE city ( +city_id integer PRIMARY KEY, +state_id integer REFERENCES state(state_id) ON DELETE CASCADE, +city_name text, +county_id integer REFERENCES county(county_id) ON DELETE CASCADE, +region_id integer REFERENCES region(region_id) ON DELETE CASCADE, +description text, +image text, +zip text, +lat double precision, +lon double precision +); + +INSERT INTO city (state_id, city_name, county_id, region_id) VALUES (1, 'Temp City', 1, 1); + +CREATE TABLE member ( +member_id integer primary key, +member_name text UNIQUE, +member_login text UNIQUE, +member_passwd text, +street text, +lat double precision, +lon double precision, +country text, +phone text, +fax text, +process_email text, +url text, +city text, +state text, +description text, +create_date date DEFAULT current_date, +zip text, +toll_free text, +member_contact_email text, +state_id integer references state(state_id) ON DELETE SET NULL, +spotlight boolean, +city_id integer references city(city_id) ON DELETE SET NULL, +logo text, +mailing_address text, +primary_contact text, +new_member boolean default 0, +primary_contact_fname text, +primary_contact_lname text, +active boolean default false, +mailing_city text, +mailing_city_id integer references city(city_id) ON DELETE SET NULL, +mailing_state_id integer references state(state_id) ON DELETE SET NULL, +mailing_zip text, +join_date date, +region integer, +time_allocated text, +type text, +facebook text, +twitter text, +myspace text, +linkedin text, +blog text, +youtube text, +account_number text +); + +CREATE TABLE member_accommodations ( +id integer PRIMARY KEY, +reservation_id text, +num_rooms integer, +year_round boolean default 0, +member_id integer REFERENCES member(member_id) ON DELETE CASCADE +); + +CREATE TABLE amenity ( +amenity_id integer PRIMARY KEY, +amenity_name text, +amenity_icon text, +display_form boolean +); + +CREATE TABLE member_amenity ( +member_amenity_id integer PRIMARY KEY, +member_id integer REFERENCES member(member_id) ON DELETE CASCADE, +amenity_id integer REFERENCES amenity(amenity_id) ON DELETE CASCADE +); + +CREATE TABLE category ( +category_id integer PRIMARY KEY, +name text NOT NULL, +parent_id integer DEFAULT 0, +pos integer DEFAULT 1, +accommodations boolean default 0, +restaurant boolean default 0, +golf boolean default 0, +code integer +); + +DELETE FROM category; +INSERT INTO category (name, parent_id, pos, accommodations, restaurant, golf) VALUES ('Parent', 0, 1, 1, 1, 1); +INSERT INTO category (name, parent_id, pos, accommodations, restaurant, golf) VALUES ('Child', 1, 1, 0, 0, 0); +INSERT INTO category (name, parent_id, pos, accommodations, restaurant, golf) VALUES ('Sibling', 1, 2, 0, 1, 0); +INSERT INTO category (name, parent_id, pos, accommodations, restaurant, golf) VALUES ('Grand Child', 2, 1, 0, 0, 1); + +CREATE TABLE member_category ( +member_category_id integer PRIMARY KEY, +member_id integer REFERENCES member(member_id) ON DELETE CASCADE, +category_id integer REFERENCES category(category_id) ON DELETE CASCADE +); + +CREATE TABLE member_contacts ( +id integer PRIMARY KEY, +title text, +fname text NOT NULL, +lname text NOT NULL, +email text, +phone text, +send_mail boolean DEFAULT 0, +member_id integer REFERENCES member(member_id) ON DELETE CASCADE +); + +CREATE TABLE member_files ( +id integer PRIMARY KEY, +file_contents text, +create_date date DEFAULT current_date, +original_name text NOT NULl, +size integer NOT NULL, +file_name text NOT NULL, +name_on_disk text NOT NULL, +pending boolean DEFAULT 1, +member_id integer REFERENCES member(member_id) ON DELETE CASCADE +); + +CREATE TABLE member_golf ( +id integer PRIMARY KEY, +par text, +yardage text, +course_rating text, +slope_rating text, +walking_course boolean DEFAULT 0, +holes18 text, +holes9 text, +member_id integer REFERENCES member(member_id) ON DELETE CASCADE +); + +CREATE TABLE member_packages ( +id integer PRIMARY KEY, +title text, +description text, +image text, +type text, +pending boolean DEFAULT 1, +pos integer, +sdate date, +edate date, +member_id integer REFERENCES member(member_id) ON DELETE CASCADE +); + +CREATE TABLE member_photos ( +id integer PRIMARY KEY, +image text NOT NULL, +caption text, +pending boolean DEFAULT 1, +pos integer DEFAULT 1, +member_id integer REFERENCES member(member_id) ON DELETE CASCADE +); + +CREATE TABLE member_restaurants ( +id integer PRIMARY KEY, +breakfast boolean DEFAULT 0, +breakfast_from text, +breakfast_to text, +brunch boolean DEFAULT 0, +brunch_from text, +brunch_to text, +lunch boolean DEFAULT 0, +lunch_from text, +lunch_to text, +dinner boolean DEFAULT 0, +dinner_from text, +dinner_to text, +alcohol boolean DEFAULT 0, +non_smoking boolean DEFAULT 0, +member_id integer REFERENCES member(member_id) ON DELETE CASCADE +); + +CREATE TABLE member_updates ( +id integer PRIMARY KEY, +field text, +'update' text, +alter_time timestamp without time zone DEFAULT current_timestamp, +db_table text NOT NULL, +data_type text, +label text, +foreign_key integer, +member_id integer REFERENCES member(member_id) ON DELETE CASCADE, +field_type text +); + +CREATE TABLE ccard_type ( +ccard_type_id integer PRIMARY KEY, +ccard_type_name text, +ccard_type_icon text +); + +DELETE FROM ccard_type; +INSERT INTO ccard_type(ccard_type_name, ccard_type_icon) VALUES ('Visa', 'cardvisa.gif'); +INSERT INTO ccard_type(ccard_type_name, ccard_type_icon) VALUES ('Master Card', 'cardmaster.gif'); +INSERT INTO ccard_type(ccard_type_name, ccard_type_icon) VALUES ('Discover', 'carddiscover.gif'); +INSERT INTO ccard_type(ccard_type_name, ccard_type_icon) VALUES ('American Express', 'cardamex.gif'); +INSERT INTO ccard_type(ccard_type_name, ccard_type_icon) VALUES ('Dinner', 'carddinner.gif'); + +CREATE TABLE member_ccard_type ( +member_ccard_type_id integer PRIMARY KEY, +member_id integer REFERENCES member(member_id) ON DELETE CASCADE, +ccard_type_id integer REFERENCES ccard_type(ccard_type_id) ON DELETE SET NULL +); + +CREATE TABLE payment_types ( +id integer PRIMARY KEY, +name TEXT NOT NULL, +category TEXT NOT NULL, +qcode INTEGER, +amount numeric(8,2) NOT NULL, +notes TEXT, +dynamic_amount BOOLEAN +); +INSERT INTO payment_types (id,name,category,qcode,amount,notes) VALUES (1,'Basic Member','sample',1545,'350.00','notes go here'); +CREATE TABLE billing ( +id integer PRIMARY KEY, +invoice_id INTEGER, +account_id INTEGER, +transaction_time time, +transaction_date date, +member_name TEXT, +member_id INTEGER, +account_number TEXT NOT NULL, +billing_type INTEGER NOT NULL, +amount numeric(11,2) NOT NULL, +balance numeric(11,2) NOT NULL, +payment_method INTEGER, +payment_data TEXT, +emailed BOOLEAN, +printed BOOLEAN, +paid BOOLEAN, +invoice TEXT, +notes TEXT +); +-- INSERT INTO billing (id,invoice_id,transaction_time,transaction_date,member_name,member_id,account_number,billing_type,amount,balance,payment_method,payment_data,sent_to_member,paid,invoice,notes) VALUES (1,1,'2009-02-02','2009-02-02','member name',1,'4545445','1','350.00','350.00',1,'#45465','f','f','',''); +CREATE TABLE member_account ( +id INTEGER, +member_id INTEGER, +account_number TEXT, +payment_type INTEGER, +email_invoice BOOLEAN, +usmail_invoice BOOLEAN, +fax_invoice BOOLEAN +); +-- INSERT INTO member_account (id,member_id,account_number,payment_type,email_invoice,usmail_invoice,fax_invoice) VALUES (1,1,'999999999',1,1,1,1); diff --git a/Toolkit/Members/files/members-seed.xml b/Toolkit/Members/files/members-seed.xml new file mode 100644 index 0000000..e2530c4 --- /dev/null +++ b/Toolkit/Members/files/members-seed.xml @@ -0,0 +1,289 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bootstrap.php b/bootstrap.php new file mode 100644 index 0000000..d3bc1d1 --- /dev/null +++ b/bootstrap.php @@ -0,0 +1,33 @@ + + + + + + /var/www/server/www.uptravel.com/Toolkit/Members/templates + /var/www/server/www.uptravel.com/setup.phtml + /var/www/server/www.uptravel.com/setup_functions.phtml + /var/www/server/www.uptravel.com/Toolkit/Common.php + /var/www/server/www.uptravel.com/Toolkit/Table.php + + + /var/www/server/www.uptravel.com/Toolkit/Billing + + +