1 | <?php |
||
2 | |||
3 | namespace AntonyThorpe\SilverShopBankDeposit\Tests; |
||
4 | |||
5 | use SilverStripe\Dev\FunctionalTest; |
||
6 | use SilverStripe\SiteConfig\SiteConfig; |
||
7 | use SilverStripe\ORM\DataObject; |
||
8 | use SilverStripe\Control\Controller; |
||
9 | use SilverShop\Tests\ShopTestControllerExtension; |
||
10 | use SilverShop\Page\AccountPage; |
||
11 | use SilverShop\Page\AccountPageController; |
||
12 | use SilverStripe\Security\Member; |
||
13 | use SilverShop\Model\Order; |
||
14 | |||
15 | /** |
||
16 | * Ensure that the template includes work on the AccountPage |
||
17 | */ |
||
18 | class BankDepositAccountPageTest extends FunctionalTest |
||
19 | { |
||
20 | protected static $fixture_file = array( |
||
21 | 'vendor/silvershop/core/tests/php/Fixtures/Pages.yml', |
||
22 | 'vendor/silvershop/core/tests/php/Fixtures/shop.yml', |
||
23 | 'vendor/silvershop/core/tests/php/Fixtures/Orders.yml', |
||
24 | 'orders.yml' |
||
25 | ); |
||
26 | |||
27 | /** |
||
28 | * @var AccountPage |
||
29 | */ |
||
30 | protected $accountpage; |
||
31 | |||
32 | /** |
||
33 | * @var AccountPageController |
||
34 | */ |
||
35 | protected $controller; |
||
36 | |||
37 | public function setUp() |
||
38 | { |
||
39 | $this->useTestTheme(dirname(__FILE__), 'testtheme', function(){}); |
||
40 | parent::setUp(); |
||
41 | ShopTest::setConfiguration(); |
||
0 ignored issues
–
show
|
|||
42 | |||
43 | $siteconfig = DataObject::get_one(SiteConfig::class); |
||
44 | $siteconfig->BankAccountPaymentMethodMessage = "You will be notified of the bank account details"; |
||
45 | $siteconfig->BankAccountNumber = "XX-3456-7891011-XX"; |
||
46 | $siteconfig->BankAccountDetails = "TestBank, Business Branch"; |
||
47 | $siteconfig->BankAccountInvoiceMessage = "Hey bo, just pop the dosh in the account"; |
||
48 | $siteconfig->write(); |
||
49 | |||
50 | Controller::add_extension(ShopTestControllerExtension::class); |
||
51 | $this->accountpage = $this->objFromFixture(AccountPage::class, "accountpage"); |
||
52 | $this->accountpage->publishSingle(); |
||
53 | $this->controller = new AccountPageController($this->accountpage); |
||
54 | } |
||
55 | |||
56 | public function testCanViewAccountPagePastOrdersAndIndividualOrders() |
||
57 | { |
||
58 | $member = $this->objFromFixture(Member::class, "joebloggs"); |
||
59 | $this->logInAs($member); |
||
60 | $this->controller->init(); //re-init to connect up member |
||
61 | |||
62 | // Open Address Book page |
||
63 | $page = $this->get("account/"); // Past Orders page |
||
64 | $this->assertEquals(AccountPageController::class, $page->getHeader('X-TestPageClass'), "Account page should open"); |
||
65 | |||
66 | $this->assertContains( |
||
67 | "Past Orders", |
||
68 | $page->getBody(), |
||
69 | "Account Page is open" |
||
70 | ); |
||
71 | $this->assertContains( |
||
72 | "Joe Bloggs", |
||
73 | $page->getBody(), |
||
74 | "Joe Bloggs is logged in" |
||
75 | ); |
||
76 | $this->assertContains( |
||
77 | "<td>$408.00</td>", |
||
78 | $page->getBody(), |
||
79 | "Past Order is listed" |
||
80 | ); |
||
81 | |||
82 | // Open unpaid order |
||
83 | $page = $this->get("account/order/10"); |
||
84 | $this->assertEquals( |
||
85 | 200, |
||
86 | $page->getStatusCode(), |
||
87 | "a page should load" |
||
88 | ); |
||
89 | $this->assertContains( |
||
90 | "Please deposit", |
||
91 | $page->getBody(), |
||
92 | "Opening statement is shown" |
||
93 | ); |
||
94 | $this->assertContains( |
||
95 | "XX-3456-7891011-XX", |
||
96 | $page->getBody(), |
||
97 | "Bank Account number is shown" |
||
98 | ); |
||
99 | $this->assertContains( |
||
100 | "Reference:", |
||
101 | $page->getBody(), |
||
102 | "Reference is shown" |
||
103 | ); |
||
104 | $this->assertContains( |
||
105 | "Your name", |
||
106 | $page->getBody(), |
||
107 | "Code is shown" |
||
108 | ); |
||
109 | $this->assertContains( |
||
110 | "<strong>$3,950.00</strong>", |
||
111 | $page->getBody(), |
||
112 | "Total Outstanding is shown" |
||
113 | ); |
||
114 | |||
115 | // Open paid order |
||
116 | $page = $this->get("account/order/11"); |
||
117 | $this->assertEquals( |
||
118 | 200, |
||
119 | $page->getStatusCode(), |
||
120 | "a page should load" |
||
121 | ); |
||
122 | $this->assertNotContains( |
||
123 | "Please deposit", |
||
124 | $page->getBody(), |
||
125 | "Opening statement is not shown" |
||
126 | ); |
||
127 | $this->assertContains( |
||
128 | "$7,900.00", |
||
129 | $page->getBody(), |
||
130 | "Total Outstanding is shown" |
||
131 | ); |
||
132 | |||
133 | $this->assertContains( |
||
134 | "Paid", |
||
135 | $page->getBody(), |
||
136 | "'Paid' is displayed in place of Total Outstanding" |
||
137 | ); |
||
138 | |||
139 | // test other order statuses |
||
140 | $order = Order::get()->byId("11"); |
||
141 | $statuses = ["Sent", "Complete", "AdminCancelled", "MemberCancelled"]; |
||
142 | foreach ($statuses as $status) { |
||
143 | $order->Status = $status; |
||
144 | |||
145 | $page = $this->get("account/order/11"); |
||
146 | $this->assertEquals( |
||
147 | 200, |
||
148 | $page->getStatusCode(), |
||
149 | "a page should load" |
||
150 | ); |
||
151 | $this->assertNotContains( |
||
152 | "Please deposit", |
||
153 | $page->getBody(), |
||
154 | "Opening statement is not shown" |
||
155 | ); |
||
156 | $this->assertContains( |
||
157 | "$7,900.00", |
||
158 | $page->getBody(), |
||
159 | "Total Outstanding is shown" |
||
160 | ); |
||
161 | $this->assertContains( |
||
162 | "Paid", |
||
163 | $page->getBody(), |
||
164 | "'Paid' is displayed in place of Total Outstanding" |
||
165 | ); |
||
166 | } |
||
167 | } |
||
168 | } |
||
169 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths