@@ -117,6 +117,7 @@ public function testPrintInvoice(): void
117
117
$ order = $ this ->orderFactory ->create ()->loadByIncrementId ('100000555 ' );
118
118
$ invoice = $ order ->getInvoiceCollection ()->getFirstItem ();
119
119
$ this ->assertNotNull ($ invoice ->getId ());
120
+ $ this ->assertTrue (is_numeric ($ invoice ->getIncrementId ()));
120
121
$ this ->registerOrder ($ order );
121
122
$ this ->registerInvoice ($ invoice );
122
123
$ blockHtml = $ this ->renderPrintInvoiceBlock ();
@@ -125,11 +126,41 @@ public function testPrintInvoice(): void
125
126
Xpath::getElementsCountForXpath (
126
127
sprintf (
127
128
"//div[contains(@class, 'order-title')]/strong[contains(text(), '%s')] " ,
128
- __ ('Invoice #%1 ' , ( int ) $ invoice ->getIncrementId ())
129
+ __ ('Invoice #%1 ' , $ invoice ->getIncrementId ())
129
130
),
130
131
$ blockHtml
131
132
),
132
- sprintf ('Title for %s was not found. ' , __ ('Invoice #%1 ' , (int )$ invoice ->getIncrementId ()))
133
+ sprintf ('Title for %s was not found. ' , __ ('Invoice #%1 ' , $ invoice ->getIncrementId ()))
134
+ );
135
+ $ this ->assertOrderInformation ($ order , $ blockHtml );
136
+ }
137
+
138
+ /**
139
+ * @magentoDataFixture Magento/Sales/_files/invoices_for_items.php
140
+ *
141
+ * @return void
142
+ */
143
+ public function testPrintInvoiceWithStringPrefix (): void
144
+ {
145
+ $ order = $ this ->orderFactory ->create ()->loadByIncrementId ('100000555 ' );
146
+ $ invoice = $ order ->getInvoiceCollection ()->getFirstItem ();
147
+ $ this ->assertNotNull ($ invoice ->getId ());
148
+ // set text prefix to increment id
149
+ $ invoice ->setIncrementId ('prefix- ' . $ invoice ->getIncrementId ());
150
+ $ this ->assertFalse (is_numeric ($ invoice ->getIncrementId ()));
151
+ $ this ->registerOrder ($ order );
152
+ $ this ->registerInvoice ($ invoice );
153
+ $ blockHtml = $ this ->renderPrintInvoiceBlock ();
154
+ $ this ->assertEquals (
155
+ 1 ,
156
+ Xpath::getElementsCountForXpath (
157
+ sprintf (
158
+ "//div[contains(@class, 'order-title')]/strong[contains(text(), '%s')] " ,
159
+ __ ('Invoice #%1 ' , $ invoice ->getIncrementId ())
160
+ ),
161
+ $ blockHtml
162
+ ),
163
+ sprintf ('Title for %s was not found. ' , __ ('Invoice #%1 ' , $ invoice ->getIncrementId ()))
133
164
);
134
165
$ this ->assertOrderInformation ($ order , $ blockHtml );
135
166
}
0 commit comments