Ejemplo n.º 1
0
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
include dirname(__FILE__) . '/../../testTools.php';
$deleteQuery = Doctrine_Query::create()->delete('Invoice i')->where('i.recurring_invoice_id IS NOT NULL');
$countQuery = RecurringInvoiceQuery::create();
$browser = new SiwappTestBrowser();
$browser->signin()->info("Recurring Invoices listing")->get('recurring')->with('request')->begin()->isParameter('module', 'recurring')->isParameter('action', 'index')->end()->with('response')->begin()->isStatusCode(200)->end();
$browser->test()->is($countQuery->countPending(), 3, "There are 3 pending invoices.");
$browser->info("Pending invoices generation")->with('response')->begin()->checkElement('#pendingButton')->end()->click('Generate pending invoices now')->with('request')->begin()->isParameter('module', 'recurring')->isParameter('action', 'generate')->end()->with('response')->begin()->isRedirected()->end()->followRedirect()->with('request')->begin()->isParameter('module', 'recurring')->isParameter('action', 'index')->end()->with('response')->begin()->isStatusCode(200)->end();
$browser->test()->is($countQuery->countPending(), 0, "No pending invoices.");
// delete generated invoices and reset recurrings status
$deleteQuery->execute();
foreach (RecurringInvoiceQuery::create()->execute() as $r) {
    $r->refresh(true);
    $r->checkStatus()->save();
}
$browser->info('Testing creating a new Invoice')->get('recurring')->with('request')->begin()->isParameter('module', 'recurring')->isParameter('action', 'index')->end()->with('response')->begin()->isStatusCode(200)->end()->click('New Recurring Invoice', array())->with('request')->begin()->isParameter('module', 'recurring')->isParameter('action', 'new')->end()->with('response')->begin()->isStatusCode(200)->end()->click('Save', array('invoice' => $fake_recurring_array))->with('request')->begin()->isParameter('module', 'recurring')->isParameter('action', 'create')->end()->with('response')->begin()->isRedirected()->end()->followRedirect()->with('request')->begin()->isParameter('module', 'recurring')->isParameter('action', 'edit')->end()->info('Checking the created recurring exists in the db')->with('doctrine')->begin()->check('RecurringInvoice', array('customer_name' => $fake_recurring_array['customer_name']))->end();
$recurring = Doctrine::getTable('Common')->findOneBy('customer_name', $fake_recurring_array['customer_name']);
// change some value to edit:
$fake_recurring_array['period'] = '10';
$fake_recurring_array['terms'] = 'new test terms';
$browser->info('Testing the editing of a recurring invoice')->get('recurring/edit/' . $recurring->id)->with('request')->begin()->isParameter('module', 'recurring')->isParameter('action', 'edit')->end()->click('Save', array('invoice' => $fake_recurring_array))->with('request')->begin()->isParameter('module', 'recurring')->isParameter('action', 'update')->end()->with('response')->begin()->isRedirected()->end()->followRedirect()->with('request')->begin()->isParameter('module', 'recurring')->isParameter('action', 'edit')->end()->info('Checking the changed value in the database')->with('doctrine')->begin()->check('RecurringInvoice', array('id' => $recurring->id, 'period' => $fake_recurring_array['period']))->end();
$browser->info('Recurring Invoice Deleting')->call('/recurring/delete', 'POST', array('id' => $recurring->id))->with('request')->begin()->isParameter('module', 'recurring')->isParameter('action', 'delete')->end()->with('response')->begin()->isRedirected()->end()->followRedirect()->with('request')->begin()->isParameter('module', 'recurring')->isParameter('action', 'index')->end()->with('doctrine')->begin()->check('Invoice', array('id' => $recurring->id), false)->end();
Ejemplo n.º 2
0
<?php

/**
 * These tests are only for the edition of estimates
 *
 **/
include dirname(__FILE__) . '/../../bootstrap/functional.php';
include dirname(__FILE__) . '/../../testTools.php';
$browser = new SiwappTestBrowser();
//save action
$browser->signin()->get('estimates')->with('request')->begin()->isParameter('module', 'estimates')->isParameter('action', 'index')->end()->info('Testing creating a new Estimate')->with('response')->begin()->checkElement('a#new-invoice-button')->end()->click('New Estimate', array())->with('request')->begin()->isParameter('module', 'estimates')->isParameter('action', 'new')->end()->with('response')->begin()->isStatusCode(200)->end()->click('Save', array('invoice' => $fake_estimate_array))->with('request')->begin()->isParameter('module', 'estimates')->isParameter('action', 'create')->end()->with('response')->begin()->isRedirected()->end()->followRedirect()->with('request')->begin()->isParameter('module', 'estimates')->isParameter('action', 'edit')->end()->info('Checking the changed value')->with('doctrine')->begin()->check('Estimate', array('customer_name' => $fake_estimate_array['customer_name'], 'due_date' => $fake_estimate_array['due_date']))->check('Item', array('description' => $fake_estimate_array['Items'][0]['description'], 'unitary_cost' => $fake_estimate_array['Items'][0]['unitary_cost']))->end()->info('Checking the created Customer')->with('doctrine')->begin()->check('Customer', array('name' => $fake_estimate_array['customer_name'], 'email' => $fake_estimate_array['customer_email']))->end();
$estimate = Doctrine::getTable('Common')->findOneBy('customer_name', $fake_estimate_array['customer_name']);
// change some value to edit:
$fake_estimate_array['issue_date'] = '2011-01-01';
$fake_estimate_array['terms'] = 'new test terms';
$fake_estimate_array['customer_email'] = '*****@*****.**';
//edit action
$browser->info('Testing editing an Estimate')->get('/estimates/edit/' . $estimate->id)->with('request')->begin()->isParameter('module', 'estimates')->isParameter('action', 'edit')->end()->click('Save', array('invoice' => $fake_estimate_array))->with('request')->begin()->isParameter('module', 'estimates')->isParameter('action', 'update')->end()->with('response')->begin()->isRedirected()->end()->followRedirect()->with('request')->begin()->isParameter('module', 'estimates')->isParameter('action', 'edit')->end()->info('Checking the changed value in the database')->with('doctrine')->begin()->check('Estimate', array('id' => $estimate->id, 'issue_date' => $fake_estimate_array['issue_date'], 'terms' => $fake_estimate_array['terms']))->end()->info('Checking the modified customer values in the estimate doesnt affect customer')->with('doctrine')->begin()->check('Customer', array('name' => $fake_estimate_array['customer_name'], 'email' => $fake_estimate_array['customer_email']), false)->end();
//delete
$browser->info('Estimate Deleting')->call('/estimates/delete', 'POST', array('id' => $estimate->id))->with('request')->begin()->isParameter('module', 'estimates')->isParameter('action', 'delete')->end()->with('response')->begin()->isRedirected()->end()->followRedirect()->with('request')->begin()->isParameter('module', 'estimates')->isParameter('action', 'index')->end()->with('doctrine')->begin()->check('Estimate', array('id' => $estimate->id), false)->end();
Ejemplo n.º 3
0
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
include dirname(__FILE__) . '/../../testTools.php';
$browser = new SiwappTestBrowser();
$browser->get('/login')->with('request')->begin()->isParameter('module', 'sfGuardAuth')->isParameter('action', 'signin')->end()->info('  1.1 - Testing sending the activation link email')->with('response')->begin()->checkElement('input[name="username_email"]')->end()->setHttpHeader('X_REQUESTED_WITH', 'XMLHttpRequest')->get('/password_recovery', array('username_email' => 'test'))->with('request')->begin()->isParameter('module', 'sfGuardAuth')->isParameter('action', 'passwordRecovery')->end()->info('  1.1 - Testing the received activation link email')->with('mailer')->begin()->info('Testing if the activation email has been sent')->hasSent()->checkBody('/http.*password_reset\\/\\w{32}\\b/')->end();
$logger = $browser->getContext()->getMailer()->getLogger();
if ($logger->countMessages()) {
    $messages = $logger->getMessages();
}
$message = $messages[0];
preg_match('/http.*password_reset\\/[a-z,A-Z,0-9]{32}/', $message->getBody(), $matches);
$recovery_url = $matches[0];
$browser->info('  1.1 - Testing clicking on the activation link')->get($recovery_url)->with('request')->begin()->isParameter('module', 'sfGuardAuth')->isParameter('action', 'passwordReset')->end()->info('  1.1 - Testing the received password email')->with('mailer')->begin()->info('Testing if the password email has been sent')->hasSent()->checkBody('/Password:\\s*\\S{8}\\b/')->end();
$logger = $browser->getContext()->getMailer()->getLogger();
if ($logger->countMessages()) {
    $messages = $logger->getMessages();
}
$message = $messages[0];
preg_match('/Password:\\s*(\\S{8})\\b/', $message->getBody(), $matches);
$password = $matches[1];
$browser->info('  1.1 - Signing in with the new password')->signin('test', $password)->with('request')->begin()->isParameter('module', 'dashboard')->isParameter('action', 'index')->end();
$user = Doctrine::getTable('sfGuardUser')->findOneBy('username', 'test');
$user->setPassword('test');
$user->save();
$browser->info('  1.1 - Logging out')->get('/logout');
$browser->info('  1.1 - Signing in with the old password')->signin();
Ejemplo n.º 4
0
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
include dirname(__FILE__) . '/../../testTools.php';
$browser = new SiwappTestBrowser();
$browser->signin()->info('Test the send email action')->post('/invoices/batch', array('ids' => array(23, 21), 'batch_action' => 'email'))->with('mailer')->begin()->hasSent(2)->checkHeader('Subject', '/Invoicer LTD \\[Invoice: ASET-8\\]/')->checkBody('/\\.*Invoicer LTD/')->end()->with('response')->begin()->isRedirected()->end()->followRedirect()->with('request')->begin()->isParameter('module', 'invoices')->isParameter('action', 'index')->end();
// create to fake invoices to delete them
$inv1 = new Invoice();
$inv2 = new Invoice();
$inv1->fromArray($fake_invoice_array);
$inv2->fromArray($fake_invoice_array);
$inv1->save();
$inv2->save();
$browser->info('Test the batch delete action')->post('/invoices/batch', array('ids' => array($inv1->id, $inv2->id), 'batch_action' => 'delete'))->with('response')->begin()->isRedirected()->end()->followRedirect()->with('doctrine')->begin()->check('Invoice', array('id' => $inv1->id), false)->check('Invoice', array('id' => $inv2->id), false)->end();
Ejemplo n.º 5
0
<?php

/**
 * These tests are only for the edition/batch actions of customers
 *
 **/
include dirname(__FILE__) . '/../../bootstrap/functional.php';
include dirname(__FILE__) . '/../../testTools.php';
$browser = new SiwappTestBrowser();
//save action
$browser->signin()->post('customers/batch', array('batch_action' => 'delete', 'ids' => array(6)))->with('request')->begin()->isParameter('module', 'customers')->isParameter('action', 'batch')->end()->info('Testing deleting a customer with invoices')->with('response')->begin()->isRedirected()->followRedirect()->end();
$browser->info('Trying to insert customer with same name slug')->get('customers/new')->with('request')->begin()->isParameter('module', 'customers')->isParameter('action', 'new')->end()->click('Save', array('customer' => array('name' => 'Smi th andCo!', 'email' => '*****@*****.**')))->with('request')->begin()->isParameter('module', 'customers')->isParameter('action', 'create')->end()->with('response')->begin()->matches('/Name too close/')->end();
Ejemplo n.º 6
0
<?php

/**
 * These tests are only for the edition of invoices
 *
 **/
include dirname(__FILE__) . '/../../bootstrap/functional.php';
include dirname(__FILE__) . '/../../testTools.php';
$browser = new SiwappTestBrowser();
//save action
$browser->signin()->get('invoices')->with('request')->begin()->isParameter('module', 'invoices')->isParameter('action', 'index')->end()->info('Testing creating a new Invoice')->with('response')->begin()->checkElement('a#new-invoice-button')->end()->click('New Invoice', array())->with('request')->begin()->isParameter('module', 'invoices')->isParameter('action', 'new')->end()->with('response')->begin()->isStatusCode(200)->end()->click('Save', array('invoice' => $fake_invoice_array))->with('request')->begin()->isParameter('module', 'invoices')->isParameter('action', 'create')->end()->with('response')->begin()->isRedirected()->end()->followRedirect()->with('request')->begin()->isParameter('module', 'invoices')->isParameter('action', 'edit')->end()->info('Checking the changed value')->with('doctrine')->begin()->check('Invoice', array('customer_name' => $fake_invoice_array['customer_name'], 'due_date' => $fake_invoice_array['due_date']))->check('Item', array('description' => $fake_invoice_array['Items'][0]['description'], 'unitary_cost' => $fake_invoice_array['Items'][0]['unitary_cost']))->end()->info('Checking the created Customer')->with('doctrine')->begin()->check('Customer', array('name' => $fake_invoice_array['customer_name'], 'email' => $fake_invoice_array['customer_email']))->end();
$invoice = Doctrine::getTable('Common')->findOneBy('customer_name', $fake_invoice_array['customer_name']);
// change some value to edit:
$fake_invoice_array['due_date'] = '2011-01-01';
$fake_invoice_array['terms'] = 'new test terms';
$fake_invoice_array['customer_email'] = '*****@*****.**';
//edit action
$browser->info('Testing editing an Invoice')->get('/invoices/edit/' . $invoice->id)->with('request')->begin()->isParameter('module', 'invoices')->isParameter('action', 'edit')->end()->click('Save', array('invoice' => $fake_invoice_array))->with('request')->begin()->isParameter('module', 'invoices')->isParameter('action', 'update')->end()->with('response')->begin()->isRedirected()->end()->followRedirect()->with('request')->begin()->isParameter('module', 'invoices')->isParameter('action', 'edit')->end()->info('Checking the changed value in the database')->with('doctrine')->begin()->check('Invoice', array('id' => $invoice->id, 'due_date' => $fake_invoice_array['due_date'], 'terms' => $fake_invoice_array['terms']))->end()->info('Checking the modified customer values in the invoice doesnt affect customer')->with('doctrine')->begin()->check('Customer', array('name' => $fake_invoice_array['customer_name'], 'email' => $fake_invoice_array['customer_email']), false)->end();
//delete
$browser->info('Invoice Deleting')->call('/invoices/delete', 'POST', array('id' => $invoice->id))->with('request')->begin()->isParameter('module', 'invoices')->isParameter('action', 'delete')->end()->with('response')->begin()->isRedirected()->end()->followRedirect()->with('request')->begin()->isParameter('module', 'invoices')->isParameter('action', 'index')->end()->with('doctrine')->begin()->check('Invoice', array('id' => $invoice->id), false)->end();
$browser->info('Test that a closed invoice goes to show action')->get('/invoices/edit/21')->with('request')->begin()->isParameter('module', 'invoices')->isParameter('action', 'edit')->end()->with('response')->begin()->matches('/Initech/')->end();